use of cbit.vcell.geometry.CompartmentSubVolume in project vcell by virtualcell.
the class ElectricalCircuitGraph method getTotalMembraneCurrent.
/**
* Insert the method's description here.
* Creation date: (2/19/2002 12:56:13 PM)
* @return cbit.vcell.parser.Expression
* @param simContext cbit.vcell.mapping.SimulationContext
* @param membrane cbit.vcell.model.Membrane
*/
private static Expression getTotalMembraneCurrent(SimulationContext simContext, Membrane membrane, AbstractMathMapping mathMapping) throws ExpressionException {
MembraneMapping membraneMapping = (MembraneMapping) simContext.getGeometryContext().getStructureMapping(membrane);
if (!membraneMapping.getCalculateVoltage()) {
return new Expression(0.0);
}
//
// gather current terms
//
Expression currentExp = new Expression(0.0);
ReactionSpec[] reactionSpecs = simContext.getReactionContext().getReactionSpecs();
StructureMappingParameter sizeParameter = membraneMapping.getSizeParameter();
Expression area = null;
if (simContext.getGeometry().getDimension() == 0 && (sizeParameter.getExpression() == null || sizeParameter.getExpression().isZero())) {
System.out.println("size not set for membrane \"" + membrane.getName() + "\", refer to Structure Mapping in Application \"" + mathMapping.getSimulationContext().getName() + "\"");
area = membraneMapping.getNullSizeParameterValue();
} else {
area = new Expression(sizeParameter, mathMapping.getNameScope());
}
for (int i = 0; i < reactionSpecs.length; i++) {
//
if (reactionSpecs[i].isExcluded()) {
continue;
}
if (reactionSpecs[i].getReactionStep().getKinetics() instanceof DistributedKinetics) {
ReactionStep rs = reactionSpecs[i].getReactionStep();
DistributedKinetics distributedKinetics = (DistributedKinetics) rs.getKinetics();
if (rs.getStructure() == membrane) {
if (!distributedKinetics.getCurrentDensityParameter().getExpression().isZero()) {
//
// change sign convension from inward current to outward current (which is consistent with voltage convension)
//
currentExp = Expression.add(currentExp, Expression.negate(Expression.mult(new Expression(distributedKinetics.getCurrentDensityParameter(), mathMapping.getNameScope()), area)));
}
}
} else {
ReactionStep rs = reactionSpecs[i].getReactionStep();
LumpedKinetics lumpedKinetics = (LumpedKinetics) rs.getKinetics();
if (rs.getStructure() == membrane) {
if (!lumpedKinetics.getLumpedCurrentParameter().getExpression().isZero()) {
//
if (!(membraneMapping.getGeometryClass() instanceof CompartmentSubVolume)) {
throw new RuntimeException("math generation for total currents within spatial electrophysiology not yet implemented");
}
Expression lumpedCurrentSymbolExp = new Expression(lumpedKinetics.getLumpedCurrentParameter(), mathMapping.getNameScope());
currentExp = Expression.add(currentExp, Expression.negate(lumpedCurrentSymbolExp));
}
}
}
}
return currentExp.flatten();
}
use of cbit.vcell.geometry.CompartmentSubVolume in project vcell by virtualcell.
the class XmlReader method getCompartmentSubVolume.
/**
* This method returns a CompartmentSubVolume object from a XML representation.
* Creation date: (5/1/2001 5:26:17 PM)
* @return cbit.vcell.geometry.CompartmentSubVolume
* @param param org.jdom.Element
*/
private CompartmentSubVolume getCompartmentSubVolume(Element param) throws XmlParseException {
// retrieve the attributes
String name = param.getAttributeValue(XMLTags.NameAttrTag);
int handle = Integer.parseInt(param.getAttributeValue(XMLTags.HandleAttrTag));
// process the key
KeyValue key = null;
String temp = param.getAttributeValue(XMLTags.KeyValueAttrTag);
if (temp != null && temp.length() > 0 && this.readKeysFlag) {
key = new KeyValue(temp);
}
// Create the CompartmentVolume
CompartmentSubVolume newcompartment = new CompartmentSubVolume(key, handle);
// set the name
try {
newcompartment.setName(name);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("A propertyVetoException was fired when setting the name to the compartmentSubVolume " + name, e);
}
return newcompartment;
}
Aggregations