void PolymerizationProcess::initSubunits(Species* aSpecies)
{
  if(aSpecies->getIsPolymer() && !aSpecies->getIsSubunitInitialized())
    {
      std::vector<Voxel*>& molecules(aSpecies->getMolecules());
      for(std::vector<Voxel*>::iterator i(molecules.begin());
          i != molecules.end(); ++i)
        {
          initSubunit(*i, aSpecies);
        }
      aSpecies->setIsSubunitInitialized();
    }
}
int main(int argc, char *argv[])
{

#   include "setRootCase.H"
#   include "createTime.H"
#   include "createMesh.H"

    potential pot(mesh);

    moleculeCloud molecules(mesh, pot);

#   include "temperatureAndPressureVariables.H"

#   include "readmdEquilibrationDict.H"

    label nAveragingSteps = 0;

    Info << "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {

        nAveragingSteps++;

        Info << "Time = " << runTime.timeName() << endl;

        molecules.evolve();

#       include "meanMomentumEnergyAndNMols.H"

#       include "temperatureAndPressure.H"

#       include "temperatureEquilibration.H"

        runTime.write();

        if (runTime.outputTime())
        {
            nAveragingSteps = 0;
        }

        Info << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info << "End\n" << endl;

    return 0;
}
Exemple #3
0
void MainWindow::reindexAtoms()
{
   bool all(false); // we only want the visible molecules;
   MoleculeList molecules(m_viewerModel.moleculeList(all));

   if (molecules.size() == 0) return;
   if (molecules.size() > 1) {
      QString msg("Only one molecule can be visible when reindexing atoms.");
      QMsgBox::warning(0, "IQmol", msg);
      return;
   }

   QList<QAction*>::iterator iter;
   for (iter = m_labelActions.begin(); iter != m_labelActions.end(); ++iter) {
       (*iter)->setChecked(false); 
   }

   m_viewer.reindexAtoms(molecules.first());
}
int main(int argc, char *argv[])
{
#   include "setRootCase.H"
#   include "createTime.H"
#   include "createMesh.H"
#   include "createRandom.H"    

    reducedUnits rU(runTime, mesh);

    constantMoleculeProperties cP (mesh, rU);
        
    polyMoleculeCloud molecules
    (
        runTime,
        mesh,
        rU,
        cP,
        rndGen,
        "mdInitialise",
        true
    );    
    
    IOstream::defaultPrecision(15);

    if (!mesh.write())
    {
        FatalErrorIn(args.executable())
            << "Failed writing moleculeCloud."
            << nl << exit(FatalError);
    }

    Info<< nl << "ClockTime = " << runTime.elapsedClockTime() << " s"
        << nl << endl;

    Info << nl << "End\n" << endl;

    return 0;
}
Exemple #5
0
void BuildAtom::leftMouseMoveEvent(QMouseEvent* e) 
{
   m_viewer->clearSelection();
   m_viewer->QGLViewer::select(e);

   // Remove from the selection any objects we may have created during 
   // the current mouse action.  (I think this is redundant now)
   m_viewer->m_selectedObjects.removeAll(m_endAtom);
   m_viewer->m_selectedObjects.removeAll(m_bond);

   // Any atom left over must be an existing one
   m_existingAtom = 0;
   for (int i = 0; i < m_viewer->m_selectedObjects.size(); ++i) {
      m_existingAtom = qobject_cast<Layer::Atom*>(m_viewer->m_selectedObjects[i]);
      if (m_existingAtom) break;
   }

   Vec startingMousePosition(m_beginAtom->getPosition());
   Vec currentMousePosition(m_viewer->worldCoordinatesOf(e, startingMousePosition));
   double shift((startingMousePosition-currentMousePosition).norm());

   if (shift < 0.2) {
      // We haven't moved far enough from where we started to create 
      // a second atom or bond.
      if (m_endAtom) {
         m_buildObjects.removeAll(m_endAtom);
         delete m_endAtom;
         m_endAtom = 0;
      }

      if (m_bond) {
         m_buildObjects.removeAll(m_bond);
         delete m_bond;
         m_bond = 0;
      }
   }else if (m_existingAtom ) {
	  // We have landed on an existing atom so we do not need either 
      // m_endAtom or m_bond;
      if (m_endAtom) {
         m_buildObjects.removeAll(m_endAtom);
         delete m_endAtom;
         m_endAtom = 0;
      }

      if (m_bond) {
         m_buildObjects.removeAll(m_bond);
         delete m_bond;
         m_bond = 0;
      }

      if (m_existingAtom != m_beginAtom) {
         if (!m_molecule->getBond(m_existingAtom, m_beginAtom)) {
            // bond does not already exist
            MoleculeList molecules(m_existingAtom->findLayers<Layer::Molecule>(Layer::Parents));
            if (!molecules.isEmpty() && molecules.first() == m_molecule) {
               m_bond = m_molecule->createBond(m_beginAtom, m_existingAtom);
               m_buildObjects.append(m_bond);
            }
         }
      }

   }else {
	  // We are floating out in space, create a 
      // new atom if we haven't already done so
      if (!m_endAtom) {
         // take care of any bond we may have formed
         if (m_bond) {
            m_buildObjects.removeAll(m_bond);
            delete m_bond;
            m_bond = 0;
         }

         Vec pos(m_viewer->worldCoordinatesOf(e, m_beginAtom->getPosition()));
         m_endAtom = m_molecule->createAtom(m_buildElement, pos);
         m_bond    = m_molecule->createBond(m_beginAtom, m_endAtom);
         m_buildObjects.append(m_endAtom);
         m_buildObjects.append(m_bond);
      }
      // Move the atom to where the mouse is
      m_endAtom->setPosition(m_viewer->worldCoordinatesOf(e, m_beginAtom->getPosition()));
   }

   m_viewer->updateGL();
   e->accept();
}
int main(int argc, char *argv[])
{
#   include "setRootCase.H"
#   include "createTime.H"
#   include "createMesh.H"

    IOdictionary mdInitialiseDict
    (
        IOobject
        (
            "mdInitialiseDict",
            runTime.system(),
            runTime,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE,
            false
        )
    );

    IOdictionary idListDict
    (
        IOobject
        (
            "idList",
            mesh.time().constant(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        )
    );

    potential pot(mesh, mdInitialiseDict, idListDict);

    moleculeCloud molecules(mesh, pot, mdInitialiseDict);

    label totalMolecules = molecules.size();

    if (Pstream::parRun())
    {
        reduce(totalMolecules, sumOp<label>());
    }

    Info<< nl << "Total number of molecules added: " << totalMolecules
        << nl << endl;

    IOstream::defaultPrecision(15);

    if (!mesh.write())
    {
        FatalErrorIn(args.executable())
            << "Failed writing moleculeCloud."
            << nl << exit(FatalError);
    }

    Info<< nl << "ClockTime = " << runTime.elapsedClockTime() << " s"
        << nl << endl;

    Info<< "\nEnd\n" << endl;

    return 0;
}
int main(){
	
	molecules();

}
int main(int argc, char *argv[])
{
    #include "setRootCaseLists.H"
    #include "createTime.H"
    #include "createMesh.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nReading field U\n" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

    potential pot(mesh);

    moleculeCloud molecules(mesh, pot);

    #include "temperatureAndPressureVariables.H"

    #include "readmdEquilibrationDict.H"

    label nAveragingSteps = 0;

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {
        nAveragingSteps++;

        Info<< "Time = " << runTime.timeName() << endl;

        molecules.evolve();

        #include "meanMomentumEnergyAndNMols.H"

        #include "temperatureAndPressure.H"

        #include "temperatureEquilibration.H"

        runTime.write();

        if (runTime.writeTime())
        {
            nAveragingSteps = 0;
        }

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}