Exemplo n.º 1
0
void HSolve::zombify( Eref hsolve ) const
{
    vector< Id >::const_iterator i;
	vector< ObjId > temp;

    for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
		temp.push_back( ObjId( *i, 0 ) );
    for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
        CompartmentBase::zombify( i->eref().element(),
					   ZombieCompartment::initCinfo(), hsolve.id() );

	temp.clear();
    for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
		temp.push_back( ObjId( *i, 0 ) );
	// Shell::dropClockMsgs( temp, "process" );
    for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
        CaConcBase::zombify( i->eref().element(), ZombieCaConc::initCinfo(), hsolve.id() );

	temp.clear();
    for ( i = channelId_.begin(); i != channelId_.end(); ++i )
		temp.push_back( ObjId( *i, 0 ) );
    for ( i = channelId_.begin(); i != channelId_.end(); ++i )
        HHChannelBase::zombify( i->eref().element(),
						ZombieHHChannel::initCinfo(), hsolve.id() );
}
Exemplo n.º 2
0
void HHGate::setTableA( const Eref& e, vector< double > v )
{
  if ( v.size() < 2 ) {
    cout << "Warning: HHGate::setTableA: size must be >= 2 entries on "
	 << e.id().path() << endl;
    return;
  }
  if ( checkOriginal( e.id(), "tableA" ) ) {
    isDirectTable_ = 1;
    A_ = v;
    unsigned int xdivs = A_.size() - 1;
    invDx_ = static_cast< double >( xdivs ) / ( xmax_ - xmin_ );
  }
}
Exemplo n.º 3
0
void HHGate::setAlpha( const Eref& e, vector< double > val )
{
  if ( val.size() != 5 ) {
    cout << "Error: HHGate::setAlpha on " << e.id().path() <<
      ": Number of entries on argument vector should be 5, was " <<
      val.size() << endl;
    return;
  }
  if ( checkOriginal( e.id(), "alpha" ) ) {
    alpha_ = val;
    updateTauMinf();
    updateTables();
  }
}
Exemplo n.º 4
0
void HHGate::setMinfinity( const Eref& e, vector< double > val )
{
  if ( val.size() != 5 ) {
    cout << "Error: HHGate::setMinfinity on " << e.id().path() <<
      ": Number of entries on argument vector should be 5, was " <<
      val.size() << endl;
    return;
  }
  if ( checkOriginal( e.id(), "mInfinity" ) ) {
    mInfinity_ = val;
    updateAlphaBeta();
    updateTables();
  }
}
Exemplo n.º 5
0
/* Enzymatic Reaction */
void SbmlReader::setupEnzymaticReaction( const EnzymeInfo & einfo,string name )
{
	static const Cinfo* enzymeCinfo = initEnzymeCinfo();	
	static const Finfo* k1Finfo = enzymeCinfo->findFinfo( "k1" );
	static const Finfo* k2Finfo = enzymeCinfo->findFinfo( "k2" );
	static const Finfo* k3Finfo = enzymeCinfo->findFinfo( "k3" );
	Eref E = ( einfo.enzyme )();
	Element* enzyme_ = Neutral::create( "Enzyme",name,E.id(),Id::scratchId() );//create Enzyme
	Eref complx = einfo.complex(); 
	Eref(enzyme_).add( "enz",E,"reac",ConnTainer::Default ); 
 	Eref(enzyme_).add( "cplx",complx,"reac",ConnTainer::Default ); 
	vector< Id >::const_iterator sub_itr;
	for ( sub_itr = einfo.substrates.begin(); sub_itr != einfo.substrates.end(); sub_itr++ )
	{	Eref S = (*sub_itr)();
		Eref( enzyme_ ).add( "sub",S,"reac",ConnTainer::Default ); 

	}
	vector< Id >::const_iterator prd_itr;
	for ( prd_itr = einfo.products.begin(); prd_itr != einfo.products.end(); prd_itr++ )
	{	Eref P = (*prd_itr)();
		Eref( enzyme_ ).add( "prd",P,"prd",ConnTainer::Default );

	}
	::set< double >( enzyme_, k1Finfo, einfo.k1 );
	::set< double >( enzyme_, k2Finfo, einfo.k2 );
	::set< double >( enzyme_, k3Finfo, einfo.k3 );
	::set< bool >( enzyme_,"mode",0 );
	::set( complx,"destroy" );
}
void OutputEventPort::innerInitialiseFunc( Eref e, 
                                           unsigned int width, 
                                           unsigned int offset,
                                           MUSIC::EventOutputPort* 
                                                 mPort) 
{

  myWidth_ = width;
  myOffset_ = offset;

  mPort_ = mPort;

  for(unsigned int i = 0; i < width; i++)
    {
      ostringstream name;

      name << "channel[" << i + offset << "]";

      Element* channel = Neutral::create( "OutputEventChannel", name.str(),
                                          e.id(), Id::scratchId() );
      channels_.push_back(channel);

      set< unsigned int, MUSIC::EventOutputPort* > 
        (channel, "initialise", i, mPort);
    }

}
Exemplo n.º 7
0
void Neutral::setName( const Eref& e, string name )
{
	if ( e.id().value() <= 3 ) {
		cout << "Warning: Neutral::setName on '" << e.id().path() << 
			   "'.Cannot rename core objects\n";
		return;
	}
	ObjId pa = parent( e );
	Id sibling = Neutral::child( pa.eref(), name );
	if ( sibling == Id() ) { // OK, no existing object with same name.
		e.element()->setName( name );
	} else {
		cout << "Warning: Neutral::setName: an object with the name '" <<
			name << "'\n already exists on the same parent. Not changed\n";
	}
}
Exemplo n.º 8
0
void GslStoich::setNinit( const Eref& e, double v )
{
	unsigned int i = e.index().value();
	unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
	assert( i < pools_.size() );
	assert( j < pools_[i].size() );
	pools_[i].varSinit()[j] = v;
}
Exemplo n.º 9
0
double GslStoich::getNinit( const Eref& e ) const
{
	unsigned int i = e.index().value();
	unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
	assert( i < pools_.size() );
	assert( j < pools_[i].size() );
	return pools_[i].Sinit()[j];
}
Exemplo n.º 10
0
/// Utility function to find the size of a pool. We assume one-to-one
/// match between pool indices and mesh indices: that is what they are for.
double lookupVolumeFromMesh( const Eref& e )
{
	ObjId compt = getCompt( e.id() );
	if ( compt == ObjId() )
		return 1.0;
	return LookupField< unsigned int, double >::
			get( compt, "oneVoxelVolume", e.dataIndex() );
}
Exemplo n.º 11
0
void HHChannel2D::destroyGate( const Eref& e, const Qinfo* q,
	string gateType )
{
	if ( !checkOriginal( e.id() ) ) {
		cout << "Warning: HHChannel2D::destroyGate: Not allowed from copied channel:\n" << e.id().path() << "\n";
		return;
	}
	
	if ( gateType == "X" )
		innerDestroyGate( "xGate", &xGate_, e.id() );
	else if ( gateType == "Y" )
		innerDestroyGate( "yGate", &yGate_, e.id() );
	else if ( gateType == "Z" )
		innerDestroyGate( "zGate", &zGate_, e.id() );
	else
		cout << "Warning: HHChannel2D::destroyGate: Unknown gate type '" <<
			gateType << "'. Ignored\n";
}
Exemplo n.º 12
0
void HHGate::setTableB( const Eref& e, vector< double > v )
{
  if ( checkOriginal( e.id(), "tableB" ) ) {
    isDirectTable_ = 1;
    if ( A_.size() != v.size() ) {
      cout << "Warning: HHGate::setTableB: size should be same as table A: " << v.size() << " != " << A_.size() << ". Ignoring.\n";
      return;
    }
    B_ = v;
  }
}
Exemplo n.º 13
0
void GslStoich::setN( const Eref& e, double v )
{
	unsigned int i = e.index().value(); // Later: Handle node location.
	unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
	assert( i < pools_.size() );
	assert( j < pools_[i].size() );
	pools_[i].varS()[j] = v;
	assert( i < y_.size() );
	assert( j < y_[i].size() );
	y_[i][j] = v;
}
Exemplo n.º 14
0
void HHGate::setupTau( const Eref& e,
		       vector< double > parms )
{
  if ( checkOriginal( e.id(), "setupTau" ) ) {
    if ( parms.size() != 13 ) {
      cout << "HHGate::setupTau: Error: parms.size() != 13\n";
      return;
    }
    setupTables( parms, true );
  }
}
Exemplo n.º 15
0
vector< Id > Neutral::getNeighbors( const Eref& e, string field ) const
{
	vector< Id > ret;
	const Finfo* finfo = e.element()->cinfo()->findFinfo( field );
	if ( finfo )
		e.element()->getNeighbors( ret, finfo );
	else
		cout << "Warning: Neutral::getNeighbors: Id.Field '" << 
				e.id().path() << "." << field <<
				"' not found\n";
	return ret;
}
Exemplo n.º 16
0
void Cell::reinit( const Eref& cell, ProcPtr p )
//~ void Cell::reinit( const Eref& cell, const Qinfo* q )
{
	cout << ".. Cell::reinit()" << endl;
	//~ if ( q->protectedAddToStructuralQ() )
		//~ return;
	
	// Delete existing solver
	//~ string solverPath = cell.id().path() + "/" + solverName_;
	//~ Id solver( solverPath );
	//~ if ( solver.path() == solverPath )
		//~ solver.destroy();
	
	if ( method_ == "ee" )
		return;
	
	// Find any compartment that is a descendant of this cell
	Id seed = findCompt( cell.id() );
	if ( seed == Id() ) // No compartment found.
		return;
	
	setupSolver( cell.id(), seed );
}
Exemplo n.º 17
0
void HHGate::setMin( const Eref& e, double val )
{
  if ( checkOriginal( e.id(), "min" ) ) {
    xmin_ = val;
    unsigned int xdivs = A_.size() - 1;
    if ( isDirectTable_ && xdivs > 0 ) {
      // Stuff here to stretch out table using interpolation.
      invDx_ = static_cast< double >( xdivs ) / ( xmax_ - val );
      tabFill( A_, xdivs, val, xmax_ );
      tabFill( B_, xdivs, val, xmax_ );
    } else {
      updateTables();
    }
  }
}
Exemplo n.º 18
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 );
	}
}
Exemplo n.º 19
0
void HHGate::setMax( const Eref& e, double val )
{
  if ( checkOriginal( e.id(), "max" ) ) {
    xmax_ = val;
    unsigned int xdivs = A_.size() - 1;
    if ( isDirectTable_ && xdivs > 0 ) {
      // Set up using direct assignment of table values.
      invDx_ = static_cast< double >( xdivs ) / ( val - xmin_ );
      tabFill( A_, xdivs, xmin_, val );
      tabFill( B_, xdivs, xmin_, val );
    } else {
      // Set up using functional form. here we just recalculate.
      updateTables();
    }
  }
}
Exemplo n.º 20
0
void HHGate::setDivs( const Eref& e, unsigned int val )
{
  if ( checkOriginal( e.id(), "divs" ) ) {
    if ( isDirectTable_ ) {
      invDx_ = static_cast< double >( val ) / ( xmax_ - xmin_ );
      tabFill( A_, val, xmin_, xmax_ );
      tabFill( B_, val, xmin_, xmax_ );
    } else {
      /// Stuff here to redo sizes.
      A_.resize( val + 1 );
      B_.resize( val + 1 );
      invDx_ = static_cast< double >( val ) / ( xmax_ - xmin_ );
      updateTables();
    }
  }
}
Exemplo n.º 21
0
void HHChannel::vCreateGate( const Eref& e, 
	string gateType )
{
	if ( !checkOriginal( e.id() ) ) {
		cout << "Warning: HHChannel::createGate: Not allowed from copied channel:\n" << e.id().path() << "\n";
		return;
	}

	if ( gateType == "X" )
		innerCreateGate( "xGate", &xGate_, e.id(), Id(e.id().value() + 1) );
	else if ( gateType == "Y" )
		innerCreateGate( "yGate", &yGate_, e.id(), Id(e.id().value() + 2) );
	else if ( gateType == "Z" )
		innerCreateGate( "zGate", &zGate_, e.id(), Id(e.id().value() + 3) );
	else
		cout << "Warning: HHChannel::createGate: Unknown gate type '" <<
			gateType << "'. Ignored\n";
}
Exemplo n.º 22
0
void HHGate::setupAlpha( const Eref& e,
			 vector< double > parms )
{
  if ( checkOriginal( e.id(), "setupAlpha" ) ) {
    if ( parms.size() != 13 ) {
      cout << "HHGate::setupAlpha: Error: parms.size() != 13\n";
      return;
    }
    setupTables( parms, false );
    alpha_.resize( 5, 0 );
    beta_.resize( 5, 0 );
    for ( unsigned int i = 0; i < 5; ++i )
      alpha_[i] = parms[i];
    for ( unsigned int i = 5; i < 10; ++i )
      beta_[i - 5] = parms[i];
  }
}
Exemplo n.º 23
0
/*
*  set up Michalies Menten reaction
*/
void SbmlReader::setupMMEnzymeReaction( Reaction * reac,string rid )
{
	string::size_type loc = rid.find( "_MM_Reaction_" );
	if( loc != string::npos ){
	     	int strlen = rid.length(); 
		rid.erase( loc,strlen-loc );
	}
    static const Cinfo* enzymeCinfo = initEnzymeCinfo();
	static const Finfo* kmFinfo = enzymeCinfo->findFinfo( "Km" );
	static const Finfo* kcatFinfo = enzymeCinfo->findFinfo( "kcat" );	
	unsigned int num_modifr = reac->getNumModifiers();
	for ( unsigned int m = 0; m < num_modifr; m++ )
	{	
		const ModifierSpeciesReference* modifr=reac->getModifier( m );
		string sp = modifr->getSpecies();
		Eref E = elmtMap_.find(sp)->second;
		Element* enzyme_ = Neutral::create( "Enzyme",rid,E.id(),Id::scratchId() );//create Enzyme
		KineticLaw * klaw=reac->getKineticLaw();
		vector< double > rate;
		rate.clear();
		getKLaw( klaw,true,rate );
		if ( errorFlag_ )
			return;
		else if ( !errorFlag_ ){
			::set< bool >( enzyme_,"mode",1 );
			Eref(enzyme_).add( "enz",E,"reac",ConnTainer::Default ); 
			for ( unsigned int rt = 0; rt < reac->getNumReactants(); rt++ )
			{	
				const SpeciesReference* rct = reac->getReactant( rt );
				sp=rct->getSpecies();
				Eref S = elmtMap_.find(sp)->second;
				Eref(enzyme_).add( "sub",S,"reac",ConnTainer::Default ); 
			}
			for ( unsigned int pt = 0; pt < reac->getNumProducts(); pt++ )
			{
				const SpeciesReference* pdt = reac->getProduct(pt);
				sp = pdt->getSpecies();
				Eref P = elmtMap_.find(sp)->second;
				Eref(enzyme_).add( "prd",P,"prd",ConnTainer::Default );
			}
			::set< double >( enzyme_, kcatFinfo, rate[0] );
			::set< double >( enzyme_, kmFinfo, rate[1] );
		}

	}	
}
Exemplo n.º 24
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 );
	}
}
Exemplo n.º 25
0
vector< string > Neutral::getMsgDestFunctions( const Eref& e, string field ) const
{
	vector< string > ret( 0 );
	const Finfo* finfo = e.element()->cinfo()->findFinfo( field );
	const SrcFinfo* sf = dynamic_cast< const SrcFinfo* >( finfo );
	if ( sf ) {
		vector< ObjId > tgt;
		vector< string > func;
		e.element()->getMsgTargetAndFunctions( e.dataIndex(), sf,
			tgt, func );
		return func;
	} else {
		cout << "Warning: Neutral::getMsgDestFunctions: Id.Field '" << 
				e.id().path() << "." << field <<
				"' not found or not a SrcFinfo\n";
	}
	return ret;
}
Exemplo n.º 26
0
/**
 * @brief Reinitialize
 *
 * @param e
 * @param p
 */
void Table::reinit( const Eref& e, ProcPtr p )
{
    tablePath_ = e.id().path();
    unsigned int numTick = e.element()->getTick();
    Clock* clk = reinterpret_cast<Clock*>(Id(1).eref().data());
    dt_ = clk->getTickDt( numTick );

    /** Create the default filepath for this table.  */
    if( useStreamer_ )
    {
        // The first column is variable time.
        columns_.push_back( "time" );
        // And the second column name is the name of the table.
        columns_.push_back( moose::moosePathToUserPath( tablePath_ ) );

        // If user has not set the filepath, then use the table path prefixed
        // with rootdit as path.
        if( ! outfileIsSet_ )
            setOutfile( rootdir_ +
                    moose::moosePathToUserPath(tablePath_) + '.' + format_ 
                    );
    }

    input_ = 0.0;
    vec().resize( 0 );
    lastTime_ = 0;
    vector< double > ret;
    requestOut()->send( e, &ret );
    vec().insert( vec().end(), ret.begin(), ret.end() );

    if( useStreamer_ )
    {
        zipWithTime( vec(), data_, lastTime_ );
        StreamerBase::writeToOutFile( outfile_, format_, "w", data_, columns_);
        clearVec();
        data_.clear();
        clearVec();
    }
}
void SigNeur::innerBuildTree( unsigned int parent, Eref paE, Eref e, 
	int msg1, int msg2 )
{
	unsigned int paIndex = tree_.size();
	TreeNode t( e.id(), parent, guessCompartmentCategory( e ) );
	tree_.push_back( t );
	// cout << e.name() << endl;
	Conn* c = e->targets( msg1, e.i );

	// Things are messy here because src/dest directions are flawed
	// in Element::targets.
	// The parallel moose fixes this mess, simply by checking against
	// which the originating element is. Here we need to do the same
	// explicitly.
	for ( ; c->good(); c->increment() ) {
		Eref tgtE = c->target();
		if ( tgtE == e )
			tgtE = c->source();
		if ( !( tgtE == paE ) ) {
			// cout << "paE=" << paE.name() << ", e=" << e.name() << ", msg1,2= " << msg1 << "," << msg2 << ", src=" << c->source().name() << ", tgt= " << tgtE.name() << endl;
			innerBuildTree( paIndex, e, tgtE, msg1, msg2 );
		}
	}
	delete c;
	c = e->targets( msg2, e.i );
	for ( ; c->good(); c->increment() ) {
		Eref tgtE = c->target();
		if ( tgtE == e )
			tgtE = c->source();
		if ( !( tgtE == paE ) ) {
			// cout << "paE=" << paE.name() << ", e=" << e.name() << ", msg1,2= " << msg1 << "," << msg2 << ", src=" << c->source().name() << ", tgt= " << tgtE.name() << endl;
			innerBuildTree( paIndex, e, tgtE, msg1, msg2 );
		}
	}
	delete c;
}
Exemplo n.º 28
0
double GslStoich::getDiffConst( const Eref& e ) const
{
	unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
	assert( j < pools_[ e.index().value() ].size() );
	return coreStoich()->getDiffConst( j );
}
Exemplo n.º 29
0
void GslStoich::setDiffConst( const Eref& e, double v )
{
	unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
	assert( j < pools_[ e.index().value() ].size() );
	coreStoich_.setDiffConst( j, v );
}
Exemplo n.º 30
0
unsigned int GslStoich::getSpecies( const Eref& e )
{
	unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
	assert( j < pools_[ e.index().value() ].size() );
	return coreStoich()->getSpecies( j );
}