virtual void fire(){ E0 = getVariableReference( "E0" ); Real PO2 = E0.getVariable()->getValue(); // theCurrentTime = getStepper()->getCurrentTime(); Real i = trunc( getStepper()->getCurrentTime() / 5.5 ); theCalcTime = getStepper()->getCurrentTime() - 5.5 * i; if (0 < theCalcTime <=0.36) PO2 = 186.1111 * theCalcTime + 30; else if(theCalcTime <= 2.55) PO2 = 97; else if(theCalcTime < 5.5) PO2 = 60 - 32 * (theCalcTime - 2.57)/(0.15 + (theCalcTime - 2.57)); // else if(theCalcTime == 5.5) // { //// theCalcTime = 0; // i= i+1; // } // std::cout << "i: " << i << std::endl; // std::cout << "theCalcTime: " << theCalcTime << std::endl; E0.getVariable()->setValue( PO2 ); }
void fire() { if( theLastTime < 0.0 ) { return; } Real aCurrentTime( getStepper()->getCurrentTime() ); Real aNextTime( theLastTime + Interval ); if( aNextTime >= Duration ) { theLastTime = -1; P0.setValue( 1e-20 * getSuperSystem()->getSizeN_A() ); return; } Real aTimeDifference( aCurrentTime - theLastTime ); Real aDecay( aTimeDifference * DecayFactor / Interval ); P0.setValue( Impulse * getSuperSystem()->getSizeN_A() / ( aDecay + 1 ) ); if( aTimeDifference >= Interval ) { theLastTime += Interval; } }
void System::preinitialize() { // no need to call subsystems' initialize() -- the Model does this if ( !theStepper ) { theStepper = theModel->getStepper( theStepperID ); theStepper->registerSystem( this ); } // // Set Process::theStepper. // for ( ProcessMap::const_iterator i( theProcessMap.begin() ); i != theProcessMap.end() ; ++i ) { Process* aProcess( i->second ); if( !aProcess->getStepper() ) { aProcess->setStepper( getStepper() ); } } configureSizeVariable(); }
void MoleculePopulateProcess::populateUniformSparse(Species* aSpecies) { Comp* aComp(aSpecies->getComp()); if(!aSpecies->getIsPopulated()) { if(UniformRadiusX == 1 && UniformRadiusY == 1 && UniformRadiusZ == 1 && !OriginX && !OriginY && !OriginZ) { unsigned int aSize(aSpecies->getPopulateMoleculeSize()); int availableVoxelSize(aComp->coords.size()); for(unsigned int j(0); j != aSize; ++j) { Voxel* aVoxel; do { aVoxel = theSpatiocyteStepper->coord2voxel( aComp->coords[gsl_rng_uniform_int( getStepper()->getRng(), availableVoxelSize)]); } while(aVoxel->id != aComp->vacantID); aSpecies->addMolecule(aVoxel); } } else { populateUniformRanged(aSpecies); } aSpecies->setIsPopulated(); } }
void Process::initialize() { if( !getStepper() ) { THROW_EXCEPTION_INSIDE( InitializationFailed, "No stepper is connected with [" + asString() + "]." ); } }
virtual void fire() { int col(gsl_rng_uniform_int(getStepper()->getRng(), theComp->maxCol-theComp->minCol-4)); col += theComp->minCol; theSpatiocyteStepper->growCompartment(theComp, Axis, col); theTime += theStepInterval; thePriorityQueue->moveTop(); }
void Model::deleteStepper( String const& anID ) { Stepper* aStepper( getStepper( anID ) ); if ( !aStepper->getProcessVector().empty() ) { THROW_EXCEPTION( IllegalOperation, "Stepper [" + anID + "] is relied on by one or more processes" ); } aStepper->detach(); }
virtual void initialize() { if(isInitialized) { return; } isInitialized = true; Process::initialize(); theSpatiocyteStepper = dynamic_cast<SpatiocyteStepper*>(getStepper()); theSortedVariableReferences.resize(theVariableReferenceVector.size()); for(VariableReferenceVector::iterator i(theVariableReferenceVector.begin()); i != theVariableReferenceVector.end(); ++i) { theSortedVariableReferences[(*i).getEllipsisNumber()] = *i; } for(VariableReferenceVector::iterator i(theSortedVariableReferences.begin()); i != theSortedVariableReferences.end(); ++i) { Variable* aVariable((*i).getVariable()); // if Name is HD, it is a homogeneously distributed species. // only create Species for immobile or diffusing species if(aVariable->getName() != "HD") { Species* aSpecies(theSpatiocyteStepper->addSpecies(aVariable)); theProcessSpecies.push_back(aSpecies); } if((*i).getCoefficient() > 0) { thePositiveVariableReferences.push_back(*i); } else if((*i).getCoefficient() < 0) { theNegativeVariableReferences.push_back(*i); } else { theZeroVariableReferences.push_back(*i); } } }
void PolymerizationProcess::removeContPoint(Subunit* aSubunit, Point* aPoint) { if(aSubunit->contPoints.size() == 1) { --aSubunit->contPointSize[0]; if(!aSubunit->contPointSize[0]) { aSubunit->contPoints.clear(); aSubunit->contPointSize.clear(); } return; } //If the size of contPoints is more than 1: else { for(unsigned int i(0); i != aSubunit->contPoints.size(); ++i) { if(getDistance(&aSubunit->contPoints[i], aPoint) < 0.1) { --aSubunit->contPointSize[i]; //If the size of the continuous point is zero, we need to remove //the point from the contPoints, and update the contPointSize //list size: if(!aSubunit->contPointSize[i]) { //Remove the continuous point: aSubunit->contPoints[i] = aSubunit->contPoints.back(); aSubunit->contPoints.pop_back(); //Update the size: aSubunit->contPointSize[i] = aSubunit->contPointSize.back(); aSubunit->contPointSize.pop_back(); } return; } } } std::cout << "error in remove contPoint at time:" << getStepper()->getCurrentTime() << std::endl; }
virtual double getInterval() { return getPropensity()* (-log(gsl_rng_uniform_pos(getStepper()->getRng()))); }
virtual void fire() { setFlux( gsl_ran_poisson( getStepper()->getRng(), getPropensity() ) ); }
void MoleculePopulateProcess::populateUniformRanged(Species* aSpecies) { Comp* aComp(aSpecies->getComp()); double delta(0); // Increase the compartment dimensions by delta if it is a surface // compartment: if(aComp->dimension == 2) { delta = 0.1; } double maxX(std::min(1.0, OriginX+UniformRadiusX)); double minX(std::max(-1.0, OriginX-UniformRadiusX)); double maxY(std::min(1.0, OriginY+UniformRadiusY)); double minY(std::max(-1.0, OriginY-UniformRadiusY)); double maxZ(std::min(1.0, OriginZ+UniformRadiusZ)); double minZ(std::max(-1.0, OriginZ-UniformRadiusZ)); maxX = aComp->centerPoint.x + maxX*aComp->lengthX/2*(1+delta); minX = aComp->centerPoint.x + minX*aComp->lengthX/2*(1+delta); maxY = aComp->centerPoint.y + maxY*aComp->lengthY/2*(1+delta); minY = aComp->centerPoint.y + minY*aComp->lengthY/2*(1+delta); maxZ = aComp->centerPoint.z + maxZ*aComp->lengthZ/2*(1+delta); minZ = aComp->centerPoint.z + minZ*aComp->lengthZ/2*(1+delta); std::vector<unsigned int> aCoords; for(std::vector<unsigned int>::iterator i(aComp->coords.begin()); i != aComp->coords.end(); ++i) { Voxel* aVoxel(theSpatiocyteStepper->coord2voxel(*i)); Point aPoint(theSpatiocyteStepper->coord2point(aVoxel->coord)); if(aVoxel->id == aSpecies->getVacantID() && aPoint.x < maxX && aPoint.x > minX && aPoint.y < maxY && aPoint.y > minY && aPoint.z < maxZ && aPoint.z > minZ) { aCoords.push_back(*i); } } unsigned int aSize(aSpecies->getPopulateMoleculeSize()); if(aCoords.size() < aSize) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: There are " + int2str(aSize) + " " + getIDString(aSpecies) + " molecules that must be uniformly populated in a " + "given range,\n but there are only " + int2str(aCoords.size()) + " vacant voxels of " + getIDString(aSpecies->getVacantSpecies()) + " that can be populated."); } unsigned int aCoordsArray[aCoords.size()]; for(unsigned int i(0); i != aCoords.size(); ++i) { aCoordsArray[i] = aCoords[i]; } gsl_ran_shuffle(getStepper()->getRng(), aCoordsArray, aCoords.size(), sizeof(unsigned int)); for(unsigned int i(0); i != aSize; ++i) { aSpecies->addMolecule(theSpatiocyteStepper->coord2voxel(aCoordsArray[i])); } }
GET_METHOD_DEF( Real, StepInterval, GillespieProcess ) { return getPropensity_R() * ( - log( gsl_rng_uniform_pos( getStepper()->getRng() ) ) ); }