1 package org.catacomb.numeric.difnet.model;
2
3 import org.catacomb.numeric.difnet.DiffusibleQuantity;
4 import org.catacomb.numeric.difnet.StateLink;
5 import org.catacomb.numeric.difnet.StateNode;
6 import org.catacomb.numeric.difnet.StructureLink;
7
8
9 public class BasicStateLink implements StateLink {
10
11 BasicStructureLink structure;
12
13 BasicStateNode nodeA;
14 BasicStateNode nodeB;
15
16
17 double conductance;
18 double capacitance;
19 double drive;
20
21 double intrinsicCurrent;
22
23
24
25 public BasicStateLink(BasicStructureLink bsl, BasicStateNode bsna, BasicStateNode bsnb) {
26 structure = bsl;
27 nodeA = bsna;
28 nodeB = bsnb;
29
30 conductance = structure.getConductance();
31 capacitance = structure.getCapacitance();
32
33 }
34
35
36 public StateNode getNodeA() {
37 return nodeA;
38 }
39
40 public StateNode getNodeB() {
41 return nodeB;
42 }
43
44 public double getConductance(DiffusibleQuantity dq) {
45 return conductance;
46 }
47
48 public double getCapacitance(DiffusibleQuantity dq) {
49 return capacitance;
50 }
51
52 // currents indepdnednt of link conductance, such as gating current;
53 public double getIntrinsicCurrent(DiffusibleQuantity dq) {
54 return intrinsicCurrent;
55 }
56
57 public double getDrive(DiffusibleQuantity dq) {
58 return drive;
59 }
60
61 public StructureLink getStructureLink() {
62 return structure;
63 }
64
65 }
66
67
68 /*
69
70
71
72 public void initializeState() {
73 if (cset != null) {
74 setChannelSolutions();
75 cset.setPotentialDifference(getPotentialDifference());
76 cset.equilibrate();
77 }
78 }
79
80
81
82
83
84 // ###### props.flip appears in each of these three methods ######
85 // it specifiew whether the inside of the membrane is nodeA (flip=false)
86 // or nodeB (flip-true)
87
88 public void setChannelSolutions() {
89 CcSolutionProp sa = nodeA.getSolutionProp();
90 CcSolutionProp sb = nodeB.getSolutionProp();
91 cset.setInternalSolution(props.flip ? sb : sa);
92 cset.setExternalSolution(props.flip ? sa : sb);
93 }
94
95
96 private double getPotentialDifference() {
97 double v = (nodeA.getPotential() - nodeB.getPotential());
98 if (props.flip) v = -v;
99 return v;
100 }
101
102
103 public void advance(CcTimestep timestep) {
104 current = 0.;
105 if (props.openSolutionJunction) {
106 reversal = props.getJunctionPotential(nodeA.getSolutionProp(),
107 nodeB.getSolutionProp());
108
109
110 } else if (cset != null) {
111 // *** should work out whether this is necessary *** ;
112 setChannelSolutions();
113 cset.setPotentialDifference(getPotentialDifference());
114 cset.advance(timestep);
115
116 CcLinG clg = cset.getLinearizedConductance();
117 conductance = clg.getConductance();
118 reversal = clg.getReversalPotential();
119 current = cset.getIntrinsicCurrent();
120 if (props.flip) {
121 reversal = -reversal;
122 current = -current;
123 }
124
125 if (nodeA.needsFluxes() || nodeB.needsFluxes()) {
126 NameValueSet nvs = cset.getSpecieFluxes();
127 // sign shold be different for nodeA, nodeB POSERR
128
129 if (nodeA.needsFluxes()) nodeA.incrementFluxes(nvs, props.flip,
130 timestep);
131 if (nodeB.needsFluxes()) nodeB.incrementFluxes(nvs, props.flip,
132 timestep);
133
134 }
135
136 }
137
138
139 }
140
141 */