use of cbit.vcell.math.VolumeRegionVariable in project vcell by virtualcell.
the class XmlReader method getJumpCondition.
/**
* This method returns a JumpCondition object from a XML Element.
* Creation date: (5/18/2001 5:10:10 PM)
* @return cbit.vcell.math.JumpCondition
* @param param org.jdom.Element
* @exception cbit.vcell.xml.XmlParseException The exception description.
*/
private JumpCondition getJumpCondition(Element param, MathDescription mathDesc) throws XmlParseException {
// get VolVariable ref
String varname = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
Variable var = mathDesc.getVariable(varname);
if (var == null) {
throw new XmlParseException("The reference to the Variable " + varname + ", could not be resolved!");
}
JumpCondition jumpCondition = null;
if (var instanceof VolVariable) {
jumpCondition = new JumpCondition((VolVariable) var);
} else if (var instanceof VolumeRegionVariable) {
jumpCondition = new JumpCondition((VolumeRegionVariable) var);
} else {
throw new XmlParseException("unexpected variable type for jump condition");
}
// process InFlux
String temp = param.getChildText(XMLTags.InFluxTag, vcNamespace);
Expression exp = unMangleExpression(temp);
jumpCondition.setInFlux(exp);
// process OutFlux
temp = param.getChildText(XMLTags.OutFluxTag, vcNamespace);
exp = unMangleExpression(temp);
jumpCondition.setOutFlux(exp);
return jumpCondition;
}
use of cbit.vcell.math.VolumeRegionVariable in project vcell by virtualcell.
the class XmlReader method getVolumeRegionVariable.
/**
* This method returns a VolumeRegionVariable object from a XML Element.
* Creation date: (5/16/2001 2:56:34 PM)
* @return cbit.vcell.math.VolumeRegionVariable
* @param param org.jdom.Element
*/
private VolumeRegionVariable getVolumeRegionVariable(Element param) {
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String domainStr = unMangle(param.getAttributeValue(XMLTags.DomainAttrTag));
Domain domain = null;
if (domainStr != null) {
domain = new Domain(domainStr);
}
// -- create new VolumeRegionVariable object
VolumeRegionVariable volRegVariable = new VolumeRegionVariable(name, domain);
transcribeComments(param, volRegVariable);
return volRegVariable;
}
use of cbit.vcell.math.VolumeRegionVariable in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a MathDescription object.
* Creation date: (3/2/2001 10:57:25 AM)
* @return Element
* @param mathdes cbit.vcell.math.MathDescription
*/
Element getXML(MathDescription mathdes) throws XmlParseException {
Element math = new Element(XMLTags.MathDescriptionTag);
// Add attributes
math.setAttribute(XMLTags.NameAttrTag, mangle(mathdes.getName()));
// Add annotation
if (mathdes.getDescription() != null && mathdes.getDescription().length() > 0) {
Element annotationElem = new Element(XMLTags.AnnotationTag);
annotationElem.setText(mangle(mathdes.getDescription()));
math.addContent(annotationElem);
}
List<ParticleMolecularType> particleMolecularTypes = mathdes.getParticleMolecularTypes();
for (ParticleMolecularType particleMolecularType : particleMolecularTypes) {
math.addContent(getXML(particleMolecularType));
}
// Add Constant subelements
Enumeration<Variable> enum1 = mathdes.getVariables();
/*java.util.Iterator k;
try {
VariableHash varHash = new VariableHash();
while (enum1.hasMoreElements())
varHash.addVariable((Variable)enum1.nextElement());
Variable vars [] = varHash.getReorderedVariables();
k = new ArrayList(java.util.Arrays.asList(vars)).iterator();
} catch (cbit.vcell.mapping.MappingException e) {
e.printStackTrace();
return null;
}*/
while (enum1.hasMoreElements()) {
Variable var = enum1.nextElement();
Element element = null;
if (var instanceof Constant) {
element = getXML((Constant) var);
} else if (var instanceof FilamentRegionVariable) {
element = getXML((FilamentRegionVariable) var);
} else if (var instanceof FilamentVariable) {
element = getXML((FilamentVariable) var);
} else if (var instanceof PointVariable) {
element = getXML((PointVariable) var);
} else if (var instanceof Function) {
element = getXML((Function) var);
} else if (var instanceof RandomVariable) {
element = getXML((RandomVariable) var);
} else if (var instanceof InsideVariable) {
// *** for internal use! Ignore it ***
continue;
} else if (var instanceof MembraneRegionVariable) {
element = getXML((MembraneRegionVariable) var);
} else if (var instanceof MemVariable) {
element = getXML((MemVariable) var);
} else if (var instanceof OutsideVariable) {
// *** for internal use! Ignore it ****
continue;
} else if (var instanceof VolumeRegionVariable) {
element = getXML((VolumeRegionVariable) var);
} else if (var instanceof VolVariable) {
element = getXML((VolVariable) var);
} else if (var instanceof StochVolVariable) {
// added for stochastic volumn variables
element = getXML((StochVolVariable) var);
} else if (var instanceof ParticleVariable) {
element = getXML((ParticleVariable) var);
} else if (var instanceof ParticleObservable) {
element = getXML((ParticleObservable) var);
} else {
throw new XmlParseException("An unknown variable type " + var.getClass().getName() + " was found when parsing the mathdescription " + mathdes.getName() + "!");
}
transcribeComments(var, element);
math.addContent(element);
}
// this was moved to the simspec!
/* buffer.append("\n");
if (geometry != null){
buffer.append(geometry.getXML());
}
buffer.append("\n");*/
// Add subdomains
Enumeration<SubDomain> enum2 = mathdes.getSubDomains();
while (enum2.hasMoreElements()) {
SubDomain subDomain = enum2.nextElement();
math.addContent(getXML(subDomain));
}
// Add Metadata (Version) if there is!
if (mathdes.getVersion() != null) {
math.addContent(getXML(mathdes.getVersion(), mathdes));
}
Iterator<Event> iter = mathdes.getEvents();
while (iter.hasNext()) {
math.addContent(getXML(iter.next()));
}
PostProcessingBlock postProcessingBlock = mathdes.getPostProcessingBlock();
if (postProcessingBlock.getNumDataGenerators() > 0) {
math.addContent(getXML(postProcessingBlock));
}
return math;
}
use of cbit.vcell.math.VolumeRegionVariable in project vcell by virtualcell.
the class DiffEquMathMapping method refreshVariables.
/**
* This method was created in VisualAge.
*/
private void refreshVariables() throws MappingException {
// System.out.println("MathMapping.refreshVariables()");
//
// non-constant dependent variables require a function
//
Enumeration<SpeciesContextMapping> enum1 = getSpeciesContextMappings();
while (enum1.hasMoreElements()) {
SpeciesContextMapping scm = enum1.nextElement();
SpeciesContextSpec scs = simContext.getReactionContext().getSpeciesContextSpec(scm.getSpeciesContext());
if (scm.getDependencyExpression() != null && !scs.isConstant()) {
// scm.setVariable(new Function(scm.getSpeciesContext().getName(),scm.getDependencyExpression()));
scm.setVariable(null);
}
if (getSimulationContext().hasEventAssignment(scs.getSpeciesContext())) {
scm.setDependencyExpression(null);
}
}
//
// non-constant independent variables require either a membrane or volume variable
//
enum1 = getSpeciesContextMappings();
while (enum1.hasMoreElements()) {
SpeciesContextMapping scm = (SpeciesContextMapping) enum1.nextElement();
SpeciesContextSpec scs = simContext.getReactionContext().getSpeciesContextSpec(scm.getSpeciesContext());
if (scm.getDependencyExpression() == null && (!scs.isConstant() || getSimulationContext().hasEventAssignment(scs.getSpeciesContext()))) {
StructureMapping sm = simContext.getGeometryContext().getStructureMapping(scm.getSpeciesContext().getStructure());
Structure struct = scm.getSpeciesContext().getStructure();
Domain domain = null;
if (sm.getGeometryClass() != null) {
domain = new Domain(sm.getGeometryClass());
}
if (struct instanceof Feature || struct instanceof Membrane) {
if (sm.getGeometryClass() instanceof SurfaceClass) {
if (scs.isWellMixed()) {
scm.setVariable(new MembraneRegionVariable(scm.getSpeciesContext().getName(), domain));
} else if (getSimulationContext().isStoch() && getSimulationContext().getGeometry().getDimension() > 0 && !scs.isForceContinuous()) {
scm.setVariable(new MemVariable(scm.getSpeciesContext().getName() + "_conc", domain));
} else {
scm.setVariable(new MemVariable(scm.getSpeciesContext().getName(), domain));
}
} else {
if (scs.isWellMixed()) {
scm.setVariable(new VolumeRegionVariable(scm.getSpeciesContext().getName(), domain));
} else if (getSimulationContext().isStoch() && getSimulationContext().getGeometry().getDimension() > 0 && !scs.isForceContinuous()) {
scm.setVariable(new VolVariable(scm.getSpeciesContext().getName() + "_conc", domain));
} else {
scm.setVariable(new VolVariable(scm.getSpeciesContext().getName(), domain));
}
}
} else {
throw new MappingException("class " + scm.getSpeciesContext().getStructure().getClass() + " not supported");
}
mathSymbolMapping.put(scm.getSpeciesContext(), scm.getVariable().getName());
}
}
}
use of cbit.vcell.math.VolumeRegionVariable in project vcell by virtualcell.
the class TestingFrameworkWindowManager method getVariableNamesToCompare.
// /**
// * Insert the method's description here.
// * Creation date: (11/23/2004 1:53:11 PM)
// * @return java.lang.String[]
// * @param sim1 cbit.vcell.solver.Simulation
// * @param sim2 cbit.vcell.solver.Simulation
// */
// private VariablePair[] getVariableNamesToCompare(BioModel testBioModel,SimulationSymbolTable testSymboltable, SimulationSymbolTable refSymbolTable){
// Vector<VariablePair> variablePairs = new Vector<VariablePair>();
//
// //
// // get Variables from Simulation 1
// //
// Variable refVars[] = refSymbolTable.getVariables();
// for (int i = 0;refVars!=null && i < refVars.length; i++){
// if (refVars[i] instanceof VolVariable ||
// refVars[i] instanceof StochVolVariable ||
// refVars[i] instanceof MemVariable ||
// refVars[i] instanceof VolumeRegionVariable ||
// refVars[i] instanceof MembraneRegionVariable ||
// refVars[i] instanceof FilamentVariable ||
// refVars[i] instanceof FilamentRegionVariable){
//
// VariablePair varPair = new VariablePair();
// varPair.refVariable = refVars[i];
// varPair.domain = refVars[i].getDomain();
// varPair.testVariable = null;
// variablePairs.add(varPair);
// }
// // Constant sensitivityParameter = simSymbolTable1.getSimulation().getSolverTaskDescription().getSensitivityParameter();
// // if (sensitivityParameter != null) {
// // if (simVars[i] instanceof VolVariable) {
// // hashSet.add(SensVariable.getSensName((VolVariable)simVars[i], sensitivityParameter));
// // }
// // }
// }
//
// //
// // add Variables from Simulation 2
// //
// Variable[] testVars = testSymboltable.getVariables();
// for (int i = 0;testVars!=null && i < testVars.length; i++){
// if (testVars[i] instanceof VolVariable ||
// testVars[i] instanceof MemVariable ||
// testVars[i] instanceof VolumeRegionVariable ||
// testVars[i] instanceof MembraneRegionVariable ||
// testVars[i] instanceof FilamentVariable ||
// testVars[i] instanceof FilamentRegionVariable){
//
// if(testVars[i].getDomain() == null){
// boolean BFoundMatchingName = false;
// for (int j = 0; j < variablePairs.size(); j++) {
// VariablePair varPair = variablePairs.elementAt(j);
// if(varPair.refVariable.getName().equals(testVars[i].getName())){
// varPair.testVariable = testVars[i];
// BFoundMatchingName = true;
// break;
// }
// }
// if(!BFoundMatchingName){
// //Try to find other matching variable types (e.g. functions)
// Variable dataSet1Match = refSymbolTable.getVariable(testVars[i].getName());
// if(dataSet1Match != null){
// VariablePair varPair = new VariablePair();
// varPair.refVariable = dataSet1Match;
// varPair.testVariable = testVars[i];
// varPair.domain = varPair.refVariable.getDomain();
// variablePairs.add(varPair);
// }else{
// SpeciesContext testSpeciescontext0 = testBioModel.getModel().getSpeciesContext(testVars[i].getName());
// if(testSpeciescontext0 != null){
// Species refspecies = testSpeciescontext0.getSpecies();
// Variable refVariable = refSymbolTable.getVariable(refspecies.getCommonName());
// if(refVariable != null){
// VariablePair varPair = new VariablePair();
// varPair.refVariable = refVariable;
// varPair.testVariable = testVars[i];
// varPair.domain = varPair.refVariable.getDomain();
// variablePairs.add(varPair);
// }
// }else{
// Species testSpecies = testBioModel.getModel().getSpecies(testVars[i].getName());
// if(testSpecies != null){
// for (int j = 0; j < testBioModel.getModel().getSpeciesContexts().length; j++) {
// if(testBioModel.getModel().getSpeciesContexts()[j].getSpecies() == testSpecies){
// Variable refVar = refSymbolTable.getVariable(testBioModel.getModel().getSpeciesContexts()[j].getName());
// if(refVar != null){
// VariablePair varPair = new VariablePair();
// varPair.refVariable = refVar;
// varPair.testVariable = testVars[i];
// varPair.domain = varPair.refVariable.getDomain();
// variablePairs.add(varPair);
// }
// }
// }
// }
// }
// }
// }
// }else{
//
// }
// hashSet.add(simVars[i].getName());
// }
// Constant sensitivityParameter = refSymbolTable.getSimulation().getSolverTaskDescription().getSensitivityParameter();
// if (sensitivityParameter != null) {
// if (simVars[i] instanceof VolVariable) {
// hashSet.add(SensVariable.getSensName((VolVariable)simVars[i], sensitivityParameter));
// }
// }
// }
//
// return (String[])hashSet.toArray(new String[hashSet.size()]);
// }
/**
* Insert the method's description here.
* Creation date: (11/23/2004 1:53:11 PM)
* @return java.lang.String[]
* @param sim1 cbit.vcell.solver.Simulation
* @param sim2 cbit.vcell.solver.Simulation
*/
private String[] getVariableNamesToCompare(SimulationSymbolTable simSymbolTable1, SimulationSymbolTable simSymbolTable2) {
java.util.HashSet<String> hashSet = new java.util.HashSet<String>();
//
// get Variables from Simulation 1
//
Variable[] simVars = simSymbolTable1.getVariables();
for (int i = 0; simVars != null && i < simVars.length; i++) {
if (simVars[i] instanceof VolVariable || simVars[i] instanceof StochVolVariable || simVars[i] instanceof MemVariable || simVars[i] instanceof VolumeRegionVariable || simVars[i] instanceof MembraneRegionVariable || simVars[i] instanceof FilamentVariable || simVars[i] instanceof FilamentRegionVariable) {
hashSet.add(simVars[i].getName());
}
Constant sensitivityParameter = simSymbolTable1.getSimulation().getSolverTaskDescription().getSensitivityParameter();
if (sensitivityParameter != null) {
if (simVars[i] instanceof VolVariable) {
hashSet.add(SensVariable.getSensName((VolVariable) simVars[i], sensitivityParameter));
}
}
}
//
// add Variables from Simulation 2
//
simVars = simSymbolTable2.getVariables();
for (int i = 0; simVars != null && i < simVars.length; i++) {
if (simVars[i] instanceof VolVariable || simVars[i] instanceof MemVariable || simVars[i] instanceof VolumeRegionVariable || simVars[i] instanceof MembraneRegionVariable || simVars[i] instanceof FilamentVariable || simVars[i] instanceof FilamentRegionVariable) {
hashSet.add(simVars[i].getName());
}
Constant sensitivityParameter = simSymbolTable2.getSimulation().getSolverTaskDescription().getSensitivityParameter();
if (sensitivityParameter != null) {
if (simVars[i] instanceof VolVariable) {
hashSet.add(SensVariable.getSensName((VolVariable) simVars[i], sensitivityParameter));
}
}
}
return (String[]) hashSet.toArray(new String[hashSet.size()]);
}
Aggregations