use of cbit.vcell.mapping.Electrode in project vcell by virtualcell.
the class ElectrodePanel method setelectrode1.
/**
* Set the electrode1 to a new value.
* @param newValue cbit.vcell.mapping.Electrode
*/
private void setelectrode1(Electrode newValue) {
if (ivjelectrode1 != newValue) {
try {
Electrode oldValue = getelectrode1();
/* Stop listening for events from the current object */
if (ivjelectrode1 != null) {
ivjelectrode1.removePropertyChangeListener(ivjEventHandler);
}
ivjelectrode1 = newValue;
/* Listen for events from the new object */
if (ivjelectrode1 != null) {
ivjelectrode1.addPropertyChangeListener(ivjEventHandler);
}
connPtoP1SetSource();
connEtoM5(ivjelectrode1);
firePropertyChange("electrode", oldValue, newValue);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
;
}
use of cbit.vcell.mapping.Electrode in project vcell by virtualcell.
the class ElectrodePanel method setElectrode.
/**
* Sets the electrode property (cbit.vcell.mapping.Electrode) value.
* @param electrode The new value for the property.
* @see #getElectrode
*/
public void setElectrode(Electrode electrode) {
Electrode oldValue = fieldElectrode;
fieldElectrode = electrode;
firePropertyChange("electrode", oldValue, electrode);
}
use of cbit.vcell.mapping.Electrode in project vcell by virtualcell.
the class ITextWriter method writeMembraneMapping.
protected void writeMembraneMapping(Section simContextSection, SimulationContext simContext) throws DocumentException {
GeometryContext geoContext = simContext.getGeometryContext();
if (geoContext == null) {
return;
}
Section memMapSection = null;
Table memMapTable = null;
StructureMapping[] structMappings = geoContext.getStructureMappings();
for (int i = 0; i < structMappings.length; i++) {
MembraneMapping memMapping = null;
if (structMappings[i] instanceof FeatureMapping) {
continue;
} else {
memMapping = (MembraneMapping) structMappings[i];
}
String structName = memMapping.getStructure().getName();
String initVoltage = "";
Expression tempExp = memMapping.getInitialVoltageParameter().getExpression();
VCUnitDefinition tempUnit = memMapping.getInitialVoltageParameter().getUnitDefinition();
if (tempExp != null) {
initVoltage = tempExp.infix();
if (tempUnit != null) {
initVoltage += " " + tempUnit.getSymbolUnicode();
}
}
String spCap = "";
tempExp = memMapping.getSpecificCapacitanceParameter().getExpression();
tempUnit = memMapping.getSpecificCapacitanceParameter().getUnitDefinition();
if (tempExp != null) {
spCap = tempExp.infix();
if (tempUnit != null) {
spCap += " " + tempUnit.getSymbolUnicode();
}
}
if (memMapTable == null) {
memMapTable = getTable(4, 100, 1, 3, 3);
memMapTable.addCell(createCell("Electrical Mapping - Membrane Potential", getBold(DEF_HEADER_FONT_SIZE), 4, 1, Element.ALIGN_CENTER, true));
memMapTable.addCell(createHeaderCell("Membrane", getBold(), 1));
memMapTable.addCell(createHeaderCell("Calculate V (T/F)", getBold(), 1));
memMapTable.addCell(createHeaderCell("V initial", getBold(), 1));
memMapTable.addCell(createHeaderCell("Specific Capacitance", getBold(), 1));
memMapTable.endHeaders();
}
memMapTable.addCell(createCell(structName, getFont()));
memMapTable.addCell(createCell((memMapping.getCalculateVoltage() ? " T " : " F "), getFont()));
memMapTable.addCell(createCell(initVoltage, getFont()));
memMapTable.addCell(createCell(spCap, getFont()));
}
if (memMapTable != null) {
memMapSection = simContextSection.addSection("Membrane Mapping For " + simContext.getName(), simContextSection.numberDepth() + 1);
memMapSection.add(memMapTable);
}
int[] widths = { 1, 1, 1, 5, 8 };
Table electTable = null;
ElectricalStimulus[] electricalStimuli = simContext.getElectricalStimuli();
for (int j = 0; j < electricalStimuli.length; j++) {
if (j == 0) {
electTable = getTable(5, 100, 1, 3, 3);
electTable.addCell(createCell("Electrical Mapping - Electrical Stimulus", getBold(DEF_HEADER_FONT_SIZE), 5, 1, Element.ALIGN_CENTER, true));
electTable.addCell(createHeaderCell("Stimulus Name", getBold(), 1));
electTable.addCell(createHeaderCell("Current Name", getBold(), 1));
electTable.addCell(createHeaderCell("Clamp Type", getBold(), 1));
electTable.addCell(createHeaderCell("Voltage/Current Density", getBold(), 1));
electTable.addCell(createHeaderCell("Clamp Device", getBold(), 1));
electTable.endHeaders();
}
String stimName = electricalStimuli[j].getName();
String currName = "";
String clampType = "", expStr = "";
Expression tempExp = null;
VCUnitDefinition tempUnit = null;
if (electricalStimuli[j] instanceof CurrentDensityClampStimulus) {
CurrentDensityClampStimulus stimulus = (CurrentDensityClampStimulus) electricalStimuli[j];
LocalParameter currentDensityParameter = stimulus.getCurrentDensityParameter();
tempExp = currentDensityParameter.getExpression();
tempUnit = currentDensityParameter.getUnitDefinition();
clampType = "Current Density (deprecated)";
} else if (electricalStimuli[j] instanceof TotalCurrentClampStimulus) {
TotalCurrentClampStimulus stimulus = (TotalCurrentClampStimulus) electricalStimuli[j];
LocalParameter totalCurrentParameter = stimulus.getCurrentParameter();
tempExp = totalCurrentParameter.getExpression();
tempUnit = totalCurrentParameter.getUnitDefinition();
clampType = "Current";
} else if (electricalStimuli[j] instanceof VoltageClampStimulus) {
VoltageClampStimulus stimulus = (VoltageClampStimulus) electricalStimuli[j];
Parameter voltageParameter = stimulus.getVoltageParameter();
tempExp = voltageParameter.getExpression();
tempUnit = voltageParameter.getUnitDefinition();
clampType = "Voltage";
}
if (tempExp != null) {
expStr = tempExp.infix();
if (tempUnit != null) {
expStr += " " + tempUnit.getSymbolUnicode();
}
}
electTable.addCell(createCell(stimName, getFont()));
electTable.addCell(createCell(currName, getFont()));
electTable.addCell(createCell(clampType, getFont()));
electTable.addCell(createCell(expStr, getFont()));
// add electrode info
Electrode electrode = electricalStimuli[j].getElectrode();
if (electrode == null) {
electTable.addCell(createCell("N/A", getFont()));
} else {
Coordinate c = electrode.getPosition();
String location = c.getX() + ", " + c.getY() + ", " + c.getZ();
String featureName = electrode.getFeature().getName();
electTable.addCell(createCell("(" + location + ") in " + featureName, getFont()));
}
}
if (electTable != null) {
if (memMapSection == null) {
memMapSection = simContextSection.addSection("Membrane Mapping For " + simContext.getName(), 1);
}
electTable.setWidths(widths);
memMapSection.add(electTable);
}
// add temperature
Table tempTable = getTable(1, 75, 1, 3, 3);
tempTable.setAlignment(Table.ALIGN_LEFT);
tempTable.addCell(createCell("Temperature: " + simContext.getTemperatureKelvin() + " K", getFont()));
if (memMapSection != null) {
memMapSection.add(tempTable);
}
}
use of cbit.vcell.mapping.Electrode in project vcell by virtualcell.
the class ElectricalCircuitGraph method getCircuitGraph.
/**
* Insert the method's description here.
* Creation date: (2/19/2002 11:24:04 AM)
* @return cbit.vcell.mapping.potential.Graph
* @param simContext cbit.vcell.mapping.SimulationContext
*/
public static Graph getCircuitGraph(SimulationContext simContext, AbstractMathMapping mathMapping) throws ExpressionException {
Graph graph = new Graph();
Model model = simContext.getModel();
//
// add nodes to the graph (one for each Feature)
//
Structure[] structures = model.getStructures();
for (int i = 0; i < structures.length; i++) {
if (structures[i] instanceof Feature) {
graph.addNode(new Node(structures[i].getName(), structures[i]));
}
}
//
// add edges for all current clamp electrodes (always have dependent voltages)
//
ElectricalStimulus[] stimuli = simContext.getElectricalStimuli();
Electrode groundElectrode = simContext.getGroundElectrode();
for (int i = 0; i < stimuli.length; i++) {
ElectricalStimulus stimulus = stimuli[i];
//
// get electrodes
//
Electrode probeElectrode = stimulus.getElectrode();
if (probeElectrode == null) {
throw new RuntimeException("null electrode for electrical stimulus");
}
if (groundElectrode == null) {
throw new RuntimeException("null ground electrode for electrical stimulus");
}
// if (!membraneMapping.getResolved()){
Node groundNode = graph.getNode(groundElectrode.getFeature().getName());
Node probeNode = graph.getNode(probeElectrode.getFeature().getName());
if (stimulus instanceof CurrentDensityClampStimulus) {
CurrentDensityClampStimulus ccStimulus = (CurrentDensityClampStimulus) stimulus;
ElectricalDevice device = new CurrentClampElectricalDevice(ccStimulus, mathMapping);
Edge edge = new Edge(probeNode, groundNode, device);
graph.addEdge(edge);
} else if (stimulus instanceof TotalCurrentClampStimulus) {
TotalCurrentClampStimulus ccStimulus = (TotalCurrentClampStimulus) stimulus;
ElectricalDevice device = new CurrentClampElectricalDevice(ccStimulus, mathMapping);
Edge edge = new Edge(probeNode, groundNode, device);
graph.addEdge(edge);
}
// }
}
//
// add edges for all membranes
//
ElectricalTopology electricalTopology = simContext.getModel().getElectricalTopology();
for (int i = 0; i < structures.length; i++) {
if (structures[i] instanceof Membrane) {
Membrane membrane = (Membrane) structures[i];
MembraneMapping membraneMapping = (MembraneMapping) simContext.getGeometryContext().getStructureMapping(membrane);
Feature positiveFeature = electricalTopology.getPositiveFeature(membrane);
Feature negativeFeature = electricalTopology.getNegativeFeature(membrane);
if (positiveFeature != null && negativeFeature != null) {
Node insideNode = graph.getNode(positiveFeature.getName());
Node outsideNode = graph.getNode(negativeFeature.getName());
//
// getTotalMembraneCurrent() already converts to "outwardCurrent" so that same convention as voltage
//
Expression currentSource = getTotalMembraneCurrent(simContext, membrane, mathMapping);
MembraneElectricalDevice device = new MembraneElectricalDevice(membraneMapping, mathMapping);
device.getParameterFromRole(ElectricalDevice.ROLE_TransmembraneCurrent).setExpression(currentSource);
Edge edge = new Edge(insideNode, outsideNode, device);
graph.addEdge(edge);
}
}
}
//
for (int i = 0; i < stimuli.length; i++) {
ElectricalStimulus stimulus = stimuli[i];
//
// get electrodes
//
Electrode probeElectrode = stimulus.getElectrode();
if (probeElectrode == null) {
throw new RuntimeException("null electrode for electrical stimulus");
}
if (groundElectrode == null) {
throw new RuntimeException("null ground electrode for electrical stimulus");
}
// if (!membraneMapping.getResolved()){
Node groundNode = graph.getNode(groundElectrode.getFeature().getName());
Node probeNode = graph.getNode(probeElectrode.getFeature().getName());
if (stimulus instanceof VoltageClampStimulus) {
VoltageClampStimulus vcStimulus = (VoltageClampStimulus) stimulus;
ElectricalDevice device = new VoltageClampElectricalDevice(vcStimulus, mathMapping);
Edge edge = new Edge(probeNode, groundNode, device);
graph.addEdge(edge);
}
// }
}
// System.out.println(graph);
return graph;
}
use of cbit.vcell.mapping.Electrode in project vcell by virtualcell.
the class PotentialMapping method getCircuitGraph.
/**
* Insert the method's description here.
* Creation date: (2/19/2002 11:24:04 AM)
* @return cbit.vcell.mapping.potential.Graph
* @param simContext cbit.vcell.mapping.SimulationContext
*/
private static Graph getCircuitGraph(SimulationContext simContext, MathMapping_4_8 mathMapping_4_8) throws ExpressionException {
Graph graph = new Graph();
Model model = simContext.getModel();
//
// add nodes to the graph (one for each Feature)
//
Structure[] structures = model.getStructures();
for (int i = 0; i < structures.length; i++) {
if (structures[i] instanceof Feature) {
graph.addNode(new Node(structures[i].getName(), structures[i]));
}
}
//
// add edges for all current clamp electrodes (always have dependent voltages)
//
ElectricalStimulus[] stimuli = simContext.getElectricalStimuli();
Electrode groundElectrode = simContext.getGroundElectrode();
for (int i = 0; i < stimuli.length; i++) {
ElectricalStimulus stimulus = stimuli[i];
//
// get electrodes
//
Electrode probeElectrode = stimulus.getElectrode();
if (probeElectrode == null) {
throw new RuntimeException("null electrode for electrical stimulus");
}
if (groundElectrode == null) {
throw new RuntimeException("null ground electrode for electrical stimulus");
}
// if (!membraneMapping.getResolved()){
Node groundNode = graph.getNode(groundElectrode.getFeature().getName());
Node probeNode = graph.getNode(probeElectrode.getFeature().getName());
if (stimulus instanceof CurrentDensityClampStimulus) {
CurrentDensityClampStimulus ccStimulus = (CurrentDensityClampStimulus) stimulus;
ElectricalDevice device = new CurrentClampElectricalDevice(ccStimulus, mathMapping_4_8);
Edge edge = new Edge(probeNode, groundNode, device);
graph.addEdge(edge);
} else if (stimulus instanceof TotalCurrentClampStimulus) {
TotalCurrentClampStimulus ccStimulus = (TotalCurrentClampStimulus) stimulus;
ElectricalDevice device = new CurrentClampElectricalDevice(ccStimulus, mathMapping_4_8);
Edge edge = new Edge(probeNode, groundNode, device);
graph.addEdge(edge);
}
// }
}
//
// add edges for all membranes
//
StructureTopology structTopology = simContext.getModel().getStructureTopology();
for (int i = 0; i < structures.length; i++) {
if (structures[i] instanceof Membrane) {
Membrane membrane = (Membrane) structures[i];
MembraneMapping membraneMapping = (MembraneMapping) simContext.getGeometryContext().getStructureMapping(membrane);
// if (!membraneMapping.getResolved()){
Feature insideFeature = structTopology.getInsideFeature(membrane);
Feature outsideFeature = structTopology.getOutsideFeature(membrane);
if (insideFeature != null && outsideFeature != null) {
Node insideNode = graph.getNode(insideFeature.getName());
Node outsideNode = graph.getNode(outsideFeature.getName());
// double capacitance = getTotalMembraneCapacitance(simContext,membrane).evaluateConstant();
//
// getTotalMembraneCurrent() already converts to "outwardCurrent" so that same convention as voltage
//
Expression currentSource = getTotalMembraneCurrent(simContext, membrane, mathMapping_4_8);
MembraneElectricalDevice device = new MembraneElectricalDevice(membraneMapping, mathMapping_4_8);
device.getParameterFromRole(ElectricalDevice.ROLE_TransmembraneCurrent).setExpression(currentSource);
Edge edge = new Edge(insideNode, outsideNode, device);
graph.addEdge(edge);
}
// }
}
}
//
for (int i = 0; i < stimuli.length; i++) {
ElectricalStimulus stimulus = stimuli[i];
//
// get electrodes
//
Electrode probeElectrode = stimulus.getElectrode();
if (probeElectrode == null) {
throw new RuntimeException("null electrode for electrical stimulus");
}
if (groundElectrode == null) {
throw new RuntimeException("null ground electrode for electrical stimulus");
}
// if (!membraneMapping.getResolved()){
Node groundNode = graph.getNode(groundElectrode.getFeature().getName());
Node probeNode = graph.getNode(probeElectrode.getFeature().getName());
if (stimulus instanceof VoltageClampStimulus) {
VoltageClampStimulus vcStimulus = (VoltageClampStimulus) stimulus;
ElectricalDevice device = new VoltageClampElectricalDevice(vcStimulus, mathMapping_4_8);
Edge edge = new Edge(probeNode, groundNode, device);
graph.addEdge(edge);
}
// }
}
// System.out.println(graph);
return graph;
}
Aggregations