Esempio n. 1
0
//////////////////////////////////////////////////////////////
// init operations.
//////////////////////////////////////////////////////////////
void Gsolve::initProc( const Eref& e, ProcPtr p )
{
	// vector< vector< double > > values( xfer_.size() );
	for ( unsigned int i = 0; i < xfer_.size(); ++i ) {
		XferInfo& xf = xfer_[i];
		unsigned int size = xf.xferPoolIdx.size() * xf.xferVoxel.size();
		// values[i].resize( size, 0.0 );
		vector< double > values( size, 0.0 );
		for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) {
			unsigned int vox = xf.xferVoxel[j];
			pools_[vox].xferOut( j, values, xf.xferPoolIdx );
		}
		xComptOut()->sendTo( e, xf.ksolve, e.id(), values );
	}
}
Esempio n. 2
0
void Gsolve::initReinit( const Eref& e, ProcPtr p )
{
	for ( unsigned int i = 0 ; i < pools_.size(); ++i ) {
		pools_[i].reinit( &sys_ );
	}
	// vector< vector< double > > values( xfer_.size() );
	for ( unsigned int i = 0; i < xfer_.size(); ++i ) {
		XferInfo& xf = xfer_[i];
		unsigned int size = xf.xferPoolIdx.size() * xf.xferVoxel.size();
		xf.lastValues.assign( size, 0.0 );
		for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) {
			unsigned int vox = xf.xferVoxel[j];
			pools_[ vox ].xferOut( j, xf.lastValues, xf.xferPoolIdx );
			// values[i] = xf.lastValues;
		}
		xComptOut()->sendTo( e, xf.ksolve, e.id(), xf.lastValues );
	}
}
Esempio n. 3
0
const Cinfo* Ksolve::initCinfo()
{
    ///////////////////////////////////////////////////////
    // Field definitions
    ///////////////////////////////////////////////////////

    static ValueFinfo< Ksolve, string > method (
        "method",
        "Integration method, using GSL. So far only explict. Options are:"
        "rk5: The default Runge-Kutta-Fehlberg 5th order adaptive dt method"
        "gsl: alias for the above"
        "rk4: The Runge-Kutta 4th order fixed dt method"
        "rk2: The Runge-Kutta 2,3 embedded fixed dt method"
        "rkck: The Runge-Kutta Cash-Karp (4,5) method"
        "rk8: The Runge-Kutta Prince-Dormand (8,9) method" ,
        &Ksolve::setMethod,
        &Ksolve::getMethod
    );

    static ValueFinfo< Ksolve, double > epsAbs (
        "epsAbs",
        "Absolute permissible integration error range.",
        &Ksolve::setEpsAbs,
        &Ksolve::getEpsAbs
    );

    static ValueFinfo< Ksolve, double > epsRel (
        "epsRel",
        "Relative permissible integration error range.",
        &Ksolve::setEpsRel,
        &Ksolve::getEpsRel
    );

    static ValueFinfo< Ksolve, Id > compartment(
        "compartment",
        "Compartment in which the Ksolve reaction system lives.",
        &Ksolve::setCompartment,
        &Ksolve::getCompartment
    );

    static ReadOnlyValueFinfo< Ksolve, unsigned int > numLocalVoxels(
        "numLocalVoxels",
        "Number of voxels in the core reac-diff system, on the "
        "current solver. ",
        &Ksolve::getNumLocalVoxels
    );
    static LookupValueFinfo<
    Ksolve, unsigned int, vector< double > > nVec(
        "nVec",
        "vector of pool counts. Index specifies which voxel.",
        &Ksolve::setNvec,
        &Ksolve::getNvec
    );
    static ValueFinfo< Ksolve, unsigned int > numAllVoxels(
        "numAllVoxels",
        "Number of voxels in the entire reac-diff system, "
        "including proxy voxels to represent abutting compartments.",
        &Ksolve::setNumAllVoxels,
        &Ksolve::getNumAllVoxels
    );

    static ValueFinfo< Ksolve, unsigned int > numPools(
        "numPools",
        "Number of molecular pools in the entire reac-diff system, "
        "including variable, function and buffered.",
        &Ksolve::setNumPools,
        &Ksolve::getNumPools
    );

    static ReadOnlyValueFinfo< Ksolve, double > estimatedDt(
        "estimatedDt",
        "Estimated timestep for reac system based on Euler error",
        &Ksolve::getEstimatedDt
    );
    static ReadOnlyValueFinfo< Ksolve, Id > stoich(
        "stoich",
        "Id for stoichiometry object tied to this Ksolve",
        &Ksolve::getStoich
    );


    ///////////////////////////////////////////////////////
    // DestFinfo definitions
    ///////////////////////////////////////////////////////

    static DestFinfo process( "process",
                              "Handles process call from Clock",
                              new ProcOpFunc< Ksolve >( &Ksolve::process ) );
    static DestFinfo reinit( "reinit",
                             "Handles reinit call from Clock",
                             new ProcOpFunc< Ksolve >( &Ksolve::reinit ) );

    static DestFinfo initProc( "initProc",
                               "Handles initProc call from Clock",
                               new ProcOpFunc< Ksolve >( &Ksolve::initProc ) );
    static DestFinfo initReinit( "initReinit",
                                 "Handles initReinit call from Clock",
                                 new ProcOpFunc< Ksolve >( &Ksolve::initReinit ) );

    static DestFinfo voxelVol( "voxelVol",
                               "Handles updates to all voxels. Comes from parent "
                               "ChemCompt object.",
                               new OpFunc1< Ksolve, vector< double > >(
                                   &Ksolve::updateVoxelVol )
                             );
    ///////////////////////////////////////////////////////
    // Shared definitions
    ///////////////////////////////////////////////////////
    static Finfo* procShared[] =
    {
        &process, &reinit
    };
    static SharedFinfo proc( "proc",
                             "Shared message for process and reinit. These are used for "
                             "all regular Ksolve calculations including interfacing with "
                             "the diffusion calculations by a Dsolve.",
                             procShared, sizeof( procShared ) / sizeof( const Finfo* )
                           );
    static Finfo* initShared[] =
    {
        &initProc, &initReinit
    };
    static SharedFinfo init( "init",
                             "Shared message for initProc and initReinit. This is used"
                             " when the system has cross-compartment reactions. ",
                             initShared, sizeof( initShared ) / sizeof( const Finfo* )
                           );

    static DestFinfo xComptIn( "xComptIn",
                               "Handles arriving pool 'n' values used in cross-compartment "
                               "reactions.",
                               new EpFunc2< Ksolve, Id, vector< double > >( &Ksolve::xComptIn )
                             );
    static Finfo* xComptShared[] =
    {
        xComptOut(), &xComptIn
    };
    static SharedFinfo xCompt( "xCompt",
                               "Shared message for pool exchange for cross-compartment "
                               "reactions. Exchanges latest values of all pools that "
                               "participate in such reactions.",
                               xComptShared, sizeof( xComptShared ) / sizeof( const Finfo* )
                             );

    static Finfo* ksolveFinfos[] =
    {
        &method,			// Value
        &epsAbs,			// Value
        &epsRel,			// Value
        &compartment,		// Value
        &numLocalVoxels,	// ReadOnlyValue
        &nVec,				// LookupValue
        &numAllVoxels,		// ReadOnlyValue
        &numPools,			// Value
        &estimatedDt,		// ReadOnlyValue
        &stoich,			// ReadOnlyValue
        &voxelVol,			// DestFinfo
        &xCompt,			// SharedFinfo
        &proc,				// SharedFinfo
        &init,				// SharedFinfo
    };

    static Dinfo< Ksolve > dinfo;
    static  Cinfo ksolveCinfo(
        "Ksolve",
        Neutral::initCinfo(),
        ksolveFinfos,
        sizeof(ksolveFinfos)/sizeof(Finfo *),
        &dinfo
    );

    return &ksolveCinfo;
}
Esempio n. 4
0
const Cinfo* Gsolve::initCinfo()
{
		///////////////////////////////////////////////////////
		// Field definitions
		///////////////////////////////////////////////////////
		
		static ValueFinfo< Gsolve, Id > stoich (
			"stoich",
			"Stoichiometry object for handling this reaction system.",
			&Gsolve::setStoich,
			&Gsolve::getStoich
		);

		static ValueFinfo< Gsolve, Id > compartment (
			"compartment",
			"Compartment that contains this reaction system.",
			&Gsolve::setCompartment,
			&Gsolve::getCompartment
		);

		static ReadOnlyValueFinfo< Gsolve, unsigned int > numLocalVoxels(
			"numLocalVoxels",
			"Number of voxels in the core reac-diff system, on the "
			"current solver. ",
			&Gsolve::getNumLocalVoxels
		);
		static LookupValueFinfo< 
				Gsolve, unsigned int, vector< double > > nVec(
			"nVec",
			"vector of pool counts",
			&Gsolve::setNvec,
			&Gsolve::getNvec
		);
		static ValueFinfo< Gsolve, unsigned int > numAllVoxels(
			"numAllVoxels",
			"Number of voxels in the entire reac-diff system, "
			"including proxy voxels to represent abutting compartments.",
			&Gsolve::setNumAllVoxels,
			&Gsolve::getNumAllVoxels
		);

		static ValueFinfo< Gsolve, unsigned int > numPools(
			"numPools",
			"Number of molecular pools in the entire reac-diff system, "
			"including variable, function and buffered.",
			&Gsolve::setNumPools,
			&Gsolve::getNumPools
		);

		static ValueFinfo< Gsolve, bool > useRandInit(
			"useRandInit",
			"Flag: True when using probabilistic (random) rounding. "
			"When initializing the mol# from floating-point Sinit values, "
			"we have two options. One is to look at each Sinit, and round "
			"to the nearest integer. The other is to look at each Sinit, "
			"and probabilistically round up or down depending on the  "
			"value. For example, if we had a Sinit value of 1.49,  "
			"this would always be rounded to 1.0 if the flag is false, "
			"and would be rounded to 1.0 and 2.0 in the ratio 51:49 if "
			"the flag is true. ",
			&Gsolve::setRandInit,
			&Gsolve::getRandInit
		);

		///////////////////////////////////////////////////////
		// DestFinfo definitions
		///////////////////////////////////////////////////////

		static DestFinfo process( "process",
			"Handles process call",
			new ProcOpFunc< Gsolve >( &Gsolve::process ) );
		static DestFinfo reinit( "reinit",
			"Handles reinit call",
			new ProcOpFunc< Gsolve >( &Gsolve::reinit ) );
		
		static DestFinfo voxelVol( "voxelVol",
			"Handles updates to all voxels. Comes from parent "
			"ChemCompt object.",
			new OpFunc1< Gsolve, vector< double > >(
			&Gsolve::updateVoxelVol )
		);

		static DestFinfo initProc( "initProc",
			"Handles initProc call from Clock",
			new ProcOpFunc< Gsolve >( &Gsolve::initProc ) );
		static DestFinfo initReinit( "initReinit",
			"Handles initReinit call from Clock",
			new ProcOpFunc< Gsolve >( &Gsolve::initReinit ) );

		static DestFinfo xComptIn( "xComptIn",
			"Handles arriving pool 'n' values used in cross-compartment "
			"reactions.",
			new EpFunc2< Gsolve, Id, vector< double > >( &Gsolve::xComptIn )
		);
		///////////////////////////////////////////////////////
		// Shared definitions
		///////////////////////////////////////////////////////
		static Finfo* procShared[] = {
			&process, &reinit
		};
		static SharedFinfo proc( "proc",
			"Shared message for process and reinit",
			procShared, sizeof( procShared ) / sizeof( const Finfo* )
		);

		static Finfo* initShared[] = {
			&initProc, &initReinit
		};
		static SharedFinfo init( "init",
			"Shared message for initProc and initReinit. This is used"
		    " when the system has cross-compartment reactions. ",
			initShared, sizeof( initShared ) / sizeof( const Finfo* )
		);

		static Finfo* xComptShared[] = {
			xComptOut(), &xComptIn
		};
		static SharedFinfo xCompt( "xCompt",
			"Shared message for pool exchange for cross-compartment "
			"reactions. Exchanges latest values of all pools that "
			"participate in such reactions.",
			xComptShared, sizeof( xComptShared ) / sizeof( const Finfo* )
		);
		///////////////////////////////////////////////////////

	static Finfo* gsolveFinfos[] =
	{
		&stoich,			// Value
		&numLocalVoxels,	// ReadOnlyValue
		&nVec,				// LookupValue
		&numAllVoxels,		// ReadOnlyValue
		&numPools,			// Value
		&voxelVol,			// DestFinfo
		&proc,				// SharedFinfo
		&init,				// SharedFinfo
		&xCompt,			// SharedFinfo
		// Here we put new fields that were not there in the Ksolve. 
		&useRandInit,		// Value
	};
	
	static Dinfo< Gsolve > dinfo;
	static  Cinfo gsolveCinfo(
		"Gsolve",
		Neutral::initCinfo(),
		gsolveFinfos,
		sizeof(gsolveFinfos)/sizeof(Finfo *),
		&dinfo
	);

	return &gsolveCinfo;
}