Пример #1
0
void Solver::CreateBlocksPPHH(){

    vec identifiers = zeros<vec>(0); Npphh = 0;
    for (int I=0; I<NHOLES; I++){
        for (int A=0; A<NPARTICLES; A++){

            if (Holes(I,2) == Particles(A,2) ) { // Block found

                bool IDExist = any( identifiers == Holes(I,2) );

                if ( ! IDExist){
                    identifiers.insert_rows(Npphh,1);
                    identifiers(Npphh) = Holes(I,2);
                    Npphh ++;
                }
            }
        }
    }

    blockspphh = new Block*[Npphh];

    for (int n=0; n<Npphh; n++) blockspphh[n] = new Block(basis, Nholes, Nparticles);

    for (int I=0; I<NHOLES; I++){
        for (int A=0; A<NPARTICLES; A++){

            if (Holes(I,2) == Particles(A,2)){

                uvec indices = find( identifiers == Holes(I,2) );
                int indice = indices(0);

                blockspphh[indice]->AddStates( Holes.row(I), Particles.row(A) );
            }
        }
    }

    for (int n=0; n<Npphh; n++){
        blockspphh[n]->FinishBlock();
    }

    #pragma omp parallel
    {
        int id = omp_get_thread_num();
        int threads = omp_get_num_threads();

        for (int n=id; n<Npphh; n+=threads) blockspphh[n]->Epsilonpphh();
    }
}
Пример #2
0
void FitRestraint::store_particles(ParticlesTemp ps) {
  all_ps_=get_as<Particles>(ps);
  add_particles(ps);
  //sort to rigid and not rigid members
  if (use_rigid_bodies_) {
    for(Particles::iterator it = all_ps_.begin();it != all_ps_.end(); it++) {
      if (core::RigidMember::particle_is_instance(*it)) {
        core::RigidBody rb=core::RigidMember(*it).get_rigid_body();
        part_of_rb_.push_back(*it);
        if (member_map_.find(rb) == member_map_.end()) {
          member_map_[rb]=Particles();
          rbs_.push_back(rb);
        }
        member_map_[rb].push_back(*it);
      }
      else {
        not_part_of_rb_.push_back(*it);
      }
    }
  }
  else {
    not_part_of_rb_=all_ps_;
  }
  IMP_LOG(TERSE,"number of"
          <<" particles that are not rigid bodies is:"
          <<not_part_of_rb_.size()<<", "<<part_of_rb_.size()<<" particles "<<
          " are part of "<<rbs_.size()<<" rigid bodies"<<std::endl);
}
Пример #3
0
//--------------------------------------------------------------
void testApp::setup(){

   ofSetFrameRate(60);
	ofBackground(30 ,30,30);
    
    mouseX =0;
    mouseY =0;
    
	ofSetVerticalSync(false);
	
  
    boxsize = 650;

    particles.assign(25, Particles());
    for(int i=0; i<particles.size(); ++i) {
        particles [i].boxsize = boxsize;
        particles [i].setup();
    }
program =new MainShaderProgram();
    
   
    mesh = isoSurface();
    mesh.gridsize = boxsize;
    mesh.resolution =25;
    mesh.resolutionPass2 =4;
    mesh.isoValue =0.0030;
    mesh.isoValuePass2 =0.0045;
    mesh.particles = particles;
    mesh.setup();
  
}
int NewPartnerLeptonic::Train(boca::Event const& event, PreCuts const&, Tag tag)
{
    INFO0;
    return SaveEntries(Quintets(event, [&](Quintet & quintet) {
        quintet.SetTag(tag);
        return quintet;
    }), Particles(event), tag);
}
Пример #5
0
int Higgs::Train(boca::Event const& event, PreCuts const& pre_cuts, Tag tag)
{
    INFO0;
    auto leptons = event.Leptons();
    return SaveEntries(Doublets(event, [&](Doublet & doublet) {
        return SetTag(doublet, leptons, pre_cuts, tag);
    }), Particles(event), tag, Id::higgs);
}
Пример #6
0
int WLeptonic::Train(boca::Event const &event, boca::PreCuts const &pre_cuts, Tag tag)
{
    INFO0;
    return SaveEntries(Doublets(event, [&](Doublet & doublet) -> boost::optional<Doublet> {
        if (Problematic(doublet, pre_cuts, tag)) return boost::none;
        doublet.SetTag(tag);
        return doublet;
    }), Particles(event), tag);
}
Пример #7
0
void KMLProxy::initialize(Model *m,const Particles &ps,
    const FloatKeys &atts,unsigned int num_centers){
  for(Particles::const_iterator it = ps.begin(); it != ps.end();it++)
  {ps_.push_back(*it);}
  for(FloatKeys::const_iterator it = atts.begin();
      it != atts.end();it++)
  {atts_.push_back(*it);}
  m_ = m;
  kcenters_=num_centers;
  dim_=atts.size();
  centroids_ = Particles();
  data_ = new KMData(dim_,ps_.size());
  for(unsigned int i=0;i<ps_.size(); i++) {
    for(unsigned int j=0;j<atts.size();j++){
      (*(*data_)[i])[j]=ps_[i]->get_value(atts[j]);
    }
  }
  is_init_=true;
}
Пример #8
0
int main(int argc, char* argv[]) {
    int nsteps;
    Box box = Box(20.0);
    Particles particles = Particles(400, 400, box);
    Potential potential = Potential();
    Integrator integrator = Integrator(0.0005);

    std::ofstream file;
    file.open("dump.lammpstrj");
    Dump dump = Dump(100, &file);

    std::ofstream file2;
    file2.open("thermo.out");
    Thermo thermo = Thermo(100, &file2);
    
    if (argc != 2) {
	std::cerr << "usage: " << argv[0] << " nsteps" << std::endl;
	exit(1);
    }
    nsteps = atoi(argv[1]);
    std::cout << "Initializing system..." << std::endl;
    System sys = System(&box, &particles, &potential, &integrator, &dump, &thermo);
    sys.run(nsteps);
}
Пример #9
0
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void starsim( Int_t nevents=1, Int_t rngSeed=1234 )
{ 
	gROOT->ProcessLine(".L bfc.C");
	{
		TString simple = "y2012 geant gstar usexgeom agml ";
		bfc(0, simple );
	}
	
	gSystem->Load( "libVMC.so");
	
	gSystem->Load( "StarGeneratorUtil.so" );
	gSystem->Load( "StarGeneratorEvent.so" );
	gSystem->Load( "StarGeneratorBase.so" );
	
	gSystem->Load( "libMathMore.so"   );
	gSystem->Load( "xgeometry.so"     );

	// Setup RNG seed and captuire ROOT TRandom
	StarRandom::seed(rngSeed);
	StarRandom::capture();
 
	//
	// Create the primary event generator and insert it
	// before the geant maker
	//
	//  StarPrimaryMaker *
	_primary = new StarPrimaryMaker();
	{
		_primary -> SetFileName( "kinematics.starsim.root");
		chain -> AddBefore( "geant", _primary );
	}
	
	Particles();	
	Kinematics();
	
	//
	// Initialize primary event generator and all sub makers
	//
	_primary -> Init();
	
	//
	// Setup geometry and set starsim to use agusread for input
	//
	geometry("y2012");
	command("gkine -4 0");
	command("gfile o pythia6.starsim.fzd");
	
	//
	// Setup PT and ETA distributions
	//
	
	Double_t pt0 = 3.0;
	ptDist = new TF1("ptDist","(x/[0])/(1+(x/[0])^2)^6",0.0,10.0);
	ptDist->SetParameter(0, pt0);
	ptDist->Draw();
	
	etaDist = new TF1("etaDist","-TMath::Erf(x+2.6)*TMath::Erf(x-2.6)",-0.8,+0.8);
	
	//
	// Trigger on nevents
	//
	trig( nevents );
	
	//	command("call agexit");  // Make sure that STARSIM exits properly
}
Пример #10
0
//----------------------------------------------------------------------------
void Fluids3D::CreateScene ()
{
    // Get fluid solver parameters.
    const int bound0M1 = mSmoke->GetIMax();
    const int bound1M1 = mSmoke->GetJMax();
    const int bound2M1 = mSmoke->GetKMax();
    const int bound0 = bound0M1 + 1;
    const int bound1 = bound1M1 + 1;
    const int bound2 = bound2M1 + 1;
    const int quantity = bound0*bound1*bound2;
    const float* x = mSmoke->GetX();
    const float* y = mSmoke->GetY();
    const float* z = mSmoke->GetZ();

#ifdef USE_PARTICLES
    // Create the vertex format.
    VertexFormat* vformat = VertexFormat::Create(3,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT4, 0);
#else
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT4, 0);
#endif

    // Create the vertex buffer for the cube.
#ifdef USE_PARTICLES
    const int numVertices = 4*quantity;
#else
    const int numVertices = quantity;
#endif

    int vstride = vformat->GetStride();
    VertexBuffer* vbuffer = new0 VertexBuffer(numVertices, vstride);

    int i0, i1, i2, index;

#ifdef USE_PARTICLES
    const float delta = mSmoke->GetDx();
    Float4* posSize = new1<Float4>(quantity);
    for (i2 = 0, index = 0; i2 < bound2; ++i2)
    {
        for (i1 = 0; i1 < bound1; ++i1)
        {
            for (i0 = 0; i0 < bound0; ++i0, ++index)
            {
                posSize[index] = Float4(x[i0], y[i1], z[i2], delta);
            }
        }
    }

    mCube = new0 Particles(vformat, vbuffer, 4, posSize, 1.0f);
    UpdateVertexBuffer();

    IndexBuffer* ibuffer = mCube->GetIndexBuffer();
#else
    VertexBufferAccessor vba(vformat, vbuffer);
    for (i2 = 0, index = 0; i2 < bound2; ++i2)
    {
        for (i1 = 0; i1 < bound1; ++i1)
        {
            for (i0 = 0; i0 < bound0; ++i0, ++index)
            {
                vba.Position<Float3>(index) = Float3(x[i0], y[i1], z[i2]);
            }
        }
    }

    // Create the index buffer for the cube.
    const int numIndices =
        6*bound0M1*bound1M1*bound2 +
        6*bound0M1*bound1*bound2M1 +
        6*bound0*bound1M1*bound2M1;

    IndexBuffer* ibuffer = new0 IndexBuffer(numIndices, sizeof(int));
    int* indices = (int*)ibuffer->GetData();

    const int bound01 = bound0*bound1;
    int j0, j1, j2, j3;
    for (i2 = 0; i2 < bound2; ++i2)
    {
        for (i1 = 0; i1 < bound1M1; ++i1)
        {
            for (i0 = 0; i0 < bound0M1; ++i0)
            {
                j0 = i0 + bound0*(i1 + bound1*i2);
                j1 = j0 + 1;
                j2 = j1 + bound0;
                j3 = j2 - 1;
                *indices++ = j0;
                *indices++ = j1;
                *indices++ = j2;
                *indices++ = j0;
                *indices++ = j2;
                *indices++ = j3;
            }
        }
    }

    for (i1 = 0; i1 < bound1; ++i1)
    {
        for (i2 = 0; i2 < bound2M1; ++i2)
        {
            for (i0 = 0; i0 < bound0M1; ++i0)
            {
                j0 = i0 + bound0*(i1 + bound1*i2);
                j1 = j0 + 1;
                j2 = j1 + bound01;
                j3 = j2 - 1;
                *indices++ = j0;
                *indices++ = j1;
                *indices++ = j2;
                *indices++ = j0;
                *indices++ = j2;
                *indices++ = j3;
            }
        }
    }

    for (i0 = 0; i0 < bound0; ++i0)
    {
        for (i1 = 0; i1 < bound1M1; ++i1)
        {
            for (i2 = 0; i2 < bound2M1; ++i2)
            {
                j0 = i0 + bound0*(i1 + bound1*i2);
                j1 = j0 + bound0;
                j2 = j1 + bound01;
                j3 = j2 - bound0;
                *indices++ = j0;
                *indices++ = j1;
                *indices++ = j2;
                *indices++ = j0;
                *indices++ = j2;
                *indices++ = j3;
            }
        }
    }

    mCube = new0 TriMesh(vformat, vbuffer, ibuffer);
    UpdateVertexBuffer();
#endif

    mNumIndices = ibuffer->GetNumElements();
    mIndices = new1<int>(mNumIndices);
    memcpy(mIndices, ibuffer->GetData(), mNumIndices*sizeof(int));

    // Create the cube effect.
#ifdef USE_PARTICLES
    std::string path = Environment::GetPathR("Disk.wmtf");
    Texture2D* texture = Texture2D::LoadWMTF(path);
    VisualEffectInstance* instance =
        VertexColor4TextureEffect::CreateUniqueInstance(texture,
        Shader::SF_NEAREST, Shader::SC_CLAMP_EDGE, Shader::SC_CLAMP_EDGE);
#else
    VertexColor4Effect* effect = new0 VertexColor4Effect();
    VisualEffectInstance* instance = effect->CreateInstance();
#endif

    const VisualPass* pass = instance->GetPass(0);
    AlphaState* astate = pass->GetAlphaState();
    astate->BlendEnabled = true;

    CullState* cstate = pass->GetCullState();
    cstate->Enabled = false;

    DepthState* dstate = pass->GetDepthState();
    dstate->Enabled = false;
    dstate->Writable = false;

    mCube->SetEffectInstance(instance);

    mScene = new0 Node();
    mScene->AttachChild(mCube);
}
Пример #11
0
//----------------------------------------------------------------------------
void ParticleSystems::CreateScene ()
{
    mScene = new0 Node();
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
    int vstride = vformat->GetStride();

    const int numParticles = 32;
    VertexBuffer* vbuffer = new0 VertexBuffer(4*numParticles, vstride);
    Float4* positionSizes = new1<Float4>(numParticles);
    for (int i = 0; i < numParticles; ++i)
    {
        positionSizes[i][0] = Mathf::SymmetricRandom();
        positionSizes[i][1] = Mathf::SymmetricRandom();
        positionSizes[i][2] = Mathf::SymmetricRandom();
        positionSizes[i][3] = 0.25f*Mathf::UnitRandom();
    }

    Particles* particles = new0 Particles(vformat, vbuffer, sizeof(int),
        positionSizes, 1.0f);

    particles->AttachController(new0 BloodCellController());
    mScene->AttachChild(particles);

    // Create an image with transparency.
    const int xsize = 32, ysize = 32;
    Texture2D* texture = new0 Texture2D(Texture::TF_A8R8G8B8, xsize,
        ysize, 1);
    unsigned char* data = (unsigned char*)texture->GetData(0);

    float factor = 1.0f/(xsize*xsize + ysize*ysize);
    for (int y = 0, i = 0; y < ysize; ++y)
    {
        for (int x = 0; x < xsize; ++x)
        {
            // The image is red.
            data[i++] = 0;
            data[i++] = 0;
            data[i++] = 255;

            // Semitransparent within a disk, dropping off to zero outside the
            // disk.
            int dx = 2*x - xsize;
            int dy = 2*y - ysize;
            float value = factor*(dx*dx + dy*dy);
            if (value < 0.125f)
            {
                value = Mathf::Cos(4.0f*Mathf::PI*value);
            }
            else
            {
                value = 0.0f;
            }
            data[i++] = (unsigned char)(255.0f*value);
        }
    }

    Texture2DEffect* effect = new0 Texture2DEffect(Shader::SF_LINEAR);
    effect->GetAlphaState(0, 0)->BlendEnabled = true;
    effect->GetDepthState(0, 0)->Enabled = false;
    particles->SetEffectInstance(effect->CreateInstance(texture));
}