use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class StructureAnalyzer method refreshFastSpeciesContextMappings.
/**
* This method was created in VisualAge.
*/
private void refreshFastSpeciesContextMappings() {
// System.out.println("StructureAnalyzer.refreshFastSpeciesContextMappings()");
// GeometryContext geoContext = mathMapping.getSimulationContext().getGeometryContext();
Vector<SpeciesContextMapping> scFastList = new Vector<SpeciesContextMapping>();
//
if (structures == null) {
return;
}
for (int i = 0; i < structures.length; i++) {
SpeciesContext[] speciesContexts = mathMapping_4_8.getSimulationContext().getReactionContext().getModel().getSpeciesContexts(structures[i]);
for (int j = 0; j < speciesContexts.length; j++) {
SpeciesContext sc = speciesContexts[j];
SpeciesContextMapping scm = mathMapping_4_8.getSpeciesContextMapping(sc);
SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(sc);
if (scm.getDependencyExpression() == null && scs.isConstant() == false) {
// right now all independent vars
scFastList.addElement(scm);
}
}
}
if (scFastList.size() > 0) {
fastSpeciesContextMappings = new SpeciesContextMapping[scFastList.size()];
scFastList.copyInto(fastSpeciesContextMappings);
// for (int i=0;i<fastSpeciesContextMappings.length;i++){
// System.out.println("fastSpeciesContextMappings["+i+"] = "+fastSpeciesContextMappings[i].getSpeciesContext().getName());
// }
} else {
fastSpeciesContextMappings = null;
}
// System.out.println("StructureAnalyzer.refreshFastSpeciesContextMapping(), fastSpeciesContextMappings.length = "+scFastList.size());
//
// for each reaction, get all reactionSteps associated with these structures
//
Vector<ReactionStep> rsFastList = new Vector<ReactionStep>();
ReactionSpec[] reactionSpecs = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpecs();
for (int i = 0; i < reactionSpecs.length; i++) {
ReactionStep rs = reactionSpecs[i].getReactionStep();
if (reactionSpecs[i].isExcluded()) {
continue;
}
for (int j = 0; j < structures.length; j++) {
if (rs.getStructure() == structures[j]) {
if (reactionSpecs[i].isFast()) {
rsFastList.addElement(rs);
}
}
}
}
if (rsFastList.size() > 0) {
fastReactionSteps = new ReactionStep[rsFastList.size()];
rsFastList.copyInto(fastReactionSteps);
} else {
fastReactionSteps = null;
fastSpeciesContextMappings = null;
}
// System.out.println("StructureAnalyzer.refreshFastSpeciesContextMapping(), reactionSteps.length = "+scFastList.size());
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class StructureAnalyzer method refreshTotalSpeciesContextMappings.
/**
* This method was created in VisualAge.
*/
private void refreshTotalSpeciesContextMappings() throws java.beans.PropertyVetoException {
if (structures == null) {
return;
}
// System.out.println("StructureAnalyzer.refreshSpeciesContextMappings()");
// GeometryContext geoContext = mathMapping.getSimulationContext().getGeometryContext();
Model model = mathMapping_4_8.getSimulationContext().getReactionContext().getModel();
//
// note, the order of species is specified such that the first species have priority
// when the null space is solved for dependent variables. So the order of priority
// for elimination are as follows:
//
// 1) Species involved with fast reactions.
// 2) Species not involved with fast reactions.
//
Vector<SpeciesContextMapping> scmList = new Vector<SpeciesContextMapping>();
//
for (int i = 0; i < structures.length; i++) {
SpeciesContext[] speciesContexts = model.getSpeciesContexts(structures[i]);
for (int j = 0; j < speciesContexts.length; j++) {
SpeciesContext sc = speciesContexts[j];
SpeciesContextMapping scm = mathMapping_4_8.getSpeciesContextMapping(sc);
SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(sc);
if (scm.isFastParticipant() && !scs.isConstant()) {
scmList.addElement(scm);
}
}
}
//
for (int i = 0; i < structures.length; i++) {
SpeciesContext[] speciesContexts = model.getSpeciesContexts(structures[i]);
for (int j = 0; j < speciesContexts.length; j++) {
SpeciesContext sc = speciesContexts[j];
SpeciesContextMapping scm = mathMapping_4_8.getSpeciesContextMapping(sc);
SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(sc);
if (!scm.isFastParticipant() && !scs.isConstant()) {
scmList.addElement(scm);
}
}
}
if (scmList.size() > 0) {
speciesContextMappings = new SpeciesContextMapping[scmList.size()];
scmList.copyInto(speciesContextMappings);
for (int i = 0; i < speciesContextMappings.length; i++) {
speciesContextMappings[i].setRate(new Expression(0.0));
// System.out.println("speciesContextMappings["+i+"] = "+speciesContextMappings[i].getSpeciesContext().getName());
}
} else {
speciesContextMappings = null;
}
// System.out.println("StructureAnalyzer.refreshTotalSpeciesContextMapping(), speciesContextMappings.length = "+scmList.size());
//
// get all reactionSteps associated with these structures
//
Vector<ReactionStep> rsList = new Vector<ReactionStep>();
ReactionSpec[] allReactionSpecs = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpecs();
for (int i = 0; i < allReactionSpecs.length; i++) {
if (allReactionSpecs[i].isExcluded()) {
continue;
}
ReactionStep rs = allReactionSpecs[i].getReactionStep();
for (int j = 0; j < structures.length; j++) {
if (rs.getStructure() == structures[j]) {
rsList.addElement(rs);
}
}
}
//
for (int i = 0; i < scmList.size(); i++) {
SpeciesContextMapping scm = (SpeciesContextMapping) scmList.elementAt(i);
if (scm.isPDERequired()) {
rsList.addElement(new DiffusionDummyReactionStep("DiffusionDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
}
if (scm.hasEventAssignment()) {
rsList.addElement(new EventDummyReactionStep("EventDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
}
if (scm.hasHybridReaction()) {
rsList.addElement(new HybridDummyReactionStep("HybridDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
}
SimulationContext simContext = mathMapping_4_8.getSimulationContext();
if (simContext.isStoch() && simContext.getGeometry().getDimension() > 0 && !simContext.getReactionContext().getSpeciesContextSpec(scm.getSpeciesContext()).isForceContinuous()) {
rsList.addElement(new ParticleDummyReactionStep("ParticleDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
}
}
if (rsList.size() > 0) {
reactionSteps = new ReactionStep[rsList.size()];
rsList.copyInto(reactionSteps);
} else {
reactionSteps = null;
}
// System.out.println("StructureAnalyzer.refreshTotalSpeciesContextMapping(), reactionSteps.length = "+scmList.size());
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a ReactionContext object.
* Creation date: (3/1/2001 9:03:52 PM)
* @return Element
* @param param cbit.vcell.mapping.ReactionContext
*/
private Element getXML(ReactionContext param) {
Element reactioncontext = new Element(XMLTags.ReactionContextTag);
// Add SpeciesContextSpecs
SpeciesContextSpec[] array = param.getSpeciesContextSpecs();
for (int i = 0; i < array.length; i++) {
reactioncontext.addContent(getXML(array[i]));
}
// Add ReactionSpecs
ReactionSpec[] reactionarray = param.getReactionSpecs();
for (int i = 0; i < reactionarray.length; i++) {
reactioncontext.addContent(getXML(reactionarray[i]));
}
// Add ReactionRuleSpecs
ReactionRuleSpec[] reactionRuleArray = param.getReactionRuleSpecs();
if (reactionRuleArray.length > 0) {
reactioncontext.addContent(getXML(reactionRuleArray));
}
return reactioncontext;
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class ModelOptimizationSpec method getModelParameters.
/**
* Insert the method's description here.
* Creation date: (8/22/2005 10:38:04 AM)
* @return cbit.vcell.model.Parameter[]
*/
private Parameter[] getModelParameters() {
java.util.Vector<Parameter> modelParameterList = new java.util.Vector<Parameter>();
Model model = getSimulationContext().getModel();
//
// get Model (global) parameters
//
ModelParameter[] globalParams = model.getModelParameters();
for (int i = 0; i < globalParams.length; i++) {
if (globalParams[i] != null && globalParams[i].getExpression() != null && globalParams[i].getExpression().isNumeric()) {
modelParameterList.add(globalParams[i]);
}
}
//
// get kinetic parameters that are numbers
//
ReactionStep[] reactionSteps = model.getReactionSteps();
for (int i = 0; i < reactionSteps.length; i++) {
//
// make sure ReactionSteps are "enabled"
//
ReactionSpec reactionSpec = getSimulationContext().getReactionContext().getReactionSpec(reactionSteps[i]);
if (reactionSpec == null || reactionSpec.isExcluded()) {
continue;
}
Kinetics.KineticsParameter[] kineticsParameters = reactionSteps[i].getKinetics().getKineticsParameters();
for (int j = 0; j < kineticsParameters.length; j++) {
if (kineticsParameters[j].getExpression() != null && kineticsParameters[j].getExpression().isNumeric()) {
if (((kineticsParameters[j].getRole() == Kinetics.ROLE_CurrentDensity) || (kineticsParameters[j].getRole() == Kinetics.ROLE_LumpedCurrent)) && reactionSteps[i].getPhysicsOptions() == ReactionStep.PHYSICS_MOLECULAR_ONLY) {
continue;
}
if (((kineticsParameters[j].getRole() == Kinetics.ROLE_ReactionRate) || (kineticsParameters[j].getRole() == Kinetics.ROLE_LumpedReactionRate)) && reactionSteps[i].getPhysicsOptions() == ReactionStep.PHYSICS_ELECTRICAL_ONLY) {
continue;
}
modelParameterList.add(kineticsParameters[j]);
}
}
}
//
// get initial conditions that are numbers
//
SpeciesContextSpec[] speciesContextSpecs = getSimulationContext().getReactionContext().getSpeciesContextSpecs();
for (int i = 0; i < speciesContextSpecs.length; i++) {
SpeciesContextSpec.SpeciesContextSpecParameter initParam = speciesContextSpecs[i].getInitialConditionParameter();
if (initParam != null && initParam.getExpression() != null && initParam.getExpression().isNumeric()) {
modelParameterList.add(initParam);
}
}
//
// get structure parameters
//
StructureMapping[] structureMappings = getSimulationContext().getGeometryContext().getStructureMappings();
for (int i = 0; i < structureMappings.length; i++) {
StructureMapping.StructureMappingParameter[] parameters = structureMappings[i].getParameters();
for (int j = 0; j < parameters.length; j++) {
if (parameters[j].getRole() == StructureMapping.ROLE_SpecificCapacitance && structureMappings[i] instanceof MembraneMapping && !((MembraneMapping) structureMappings[i]).getCalculateVoltage()) {
continue;
}
if (parameters[j].getExpression() != null && parameters[j].getExpression().isNumeric()) {
modelParameterList.add(parameters[j]);
}
}
}
Parameter[] modelParameters = (Parameter[]) BeanUtils.getArray(modelParameterList, Parameter.class);
return modelParameters;
}
Aggregations