|
33 | 33 | set_parameter(device="disk", region="solution", name="V_t", value=0.0238) |
34 | 34 |
|
35 | 35 | for region in ("dna", "dielectric", "solution"): |
36 | | - node_solution(device="disk", region=region, name="Potential") |
37 | | - edge_from_node_model(device="disk", region=region, node_model="Potential") |
38 | | - |
39 | | - if dimension == 2: |
40 | | - set_parameter(device="disk", name="raxis_variable", value="x") |
41 | | - set_parameter(device="disk", name="raxis_zero", value=0) |
42 | | - cylindrical_node_volume(device="disk", region=region) |
43 | | - cylindrical_edge_couple(device="disk", region=region) |
44 | | - |
45 | | - set_parameter(name="node_volume_model", value="CylindricalNodeVolume") |
46 | | - set_parameter(name="edge_couple_model", value="CylindricalEdgeCouple") |
47 | | - set_parameter(name="element_edge_couple_model", value="ElementCylindricalEdgeCouple") |
48 | | - set_parameter(name="element_node0_volume_model", value="ElementCylindricalNodeVolume@en0") |
49 | | - set_parameter(name="element_node1_volume_model", value="ElementCylindricalNodeVolume@en1") |
50 | | - |
51 | | - x=sum(get_node_model_values(device="disk", region=region, name="CylindricalNodeVolume")) |
52 | | - y=sum(get_node_model_values(device="disk", region=region, name="NodeVolume")) |
53 | | - print("Volume {0} {1} {2}".format(region, x, y)) |
54 | | - else: |
55 | | - y=sum(get_node_model_values(device="disk", region=region, name="NodeVolume")) |
56 | | - print("Volume {0} {1}".format(region, y)) |
57 | | - |
58 | | - # Electric Field Edge Model |
59 | | - edge_model(device="disk", region=region, name="EField", |
60 | | - equation="(Potential@n0 - Potential@n1)*EdgeInverseLength") |
61 | | - |
62 | | - edge_model(device="disk", region=region, name="EField:Potential@n0", |
63 | | - equation="EdgeInverseLength",) |
64 | | - |
65 | | - edge_model(device="disk", region=region, name="EField:Potential@n1", |
66 | | - equation="-EdgeInverseLength") |
67 | | - |
68 | | - edge_model(device="disk", region=region, name="DField", equation="Permittivity*EField") |
69 | | - edge_model(device="disk", region=region, name="DField:Potential@n0", equation="Permittivity*EField:Potential@n0") |
70 | | - edge_model(device="disk", region=region, name="DField:Potential@n1", equation="Permittivity*EField:Potential@n1") |
| 36 | + node_solution(device="disk", region=region, name="Potential") |
| 37 | + edge_from_node_model(device="disk", region=region, node_model="Potential") |
| 38 | + |
| 39 | + if dimension == 2: |
| 40 | + set_parameter(device="disk", name="raxis_variable", value="x") |
| 41 | + set_parameter(device="disk", name="raxis_zero", value=0) |
| 42 | + cylindrical_node_volume(device="disk", region=region) |
| 43 | + cylindrical_edge_couple(device="disk", region=region) |
| 44 | + |
| 45 | + set_parameter(name="node_volume_model", value="CylindricalNodeVolume") |
| 46 | + set_parameter(name="edge_couple_model", value="CylindricalEdgeCouple") |
| 47 | + set_parameter(name="element_edge_couple_model", value="ElementCylindricalEdgeCouple") |
| 48 | + set_parameter(name="element_node0_volume_model", value="ElementCylindricalNodeVolume@en0") |
| 49 | + set_parameter(name="element_node1_volume_model", value="ElementCylindricalNodeVolume@en1") |
| 50 | + |
| 51 | + x=sum(get_node_model_values(device="disk", region=region, name="CylindricalNodeVolume")) |
| 52 | + y=sum(get_node_model_values(device="disk", region=region, name="NodeVolume")) |
| 53 | + print("Volume {0} {1} {2}".format(region, x, y)) |
| 54 | + else: |
| 55 | + y=sum(get_node_model_values(device="disk", region=region, name="NodeVolume")) |
| 56 | + print("Volume {0} {1}".format(region, y)) |
| 57 | + |
| 58 | + # Electric Field Edge Model |
| 59 | + edge_model(device="disk", region=region, name="EField", |
| 60 | + equation="(Potential@n0 - Potential@n1)*EdgeInverseLength") |
| 61 | + |
| 62 | + edge_model(device="disk", region=region, name="EField:Potential@n0", |
| 63 | + equation="EdgeInverseLength",) |
| 64 | + |
| 65 | + edge_model(device="disk", region=region, name="EField:Potential@n1", |
| 66 | + equation="-EdgeInverseLength") |
| 67 | + |
| 68 | + edge_model(device="disk", region=region, name="DField", equation="Permittivity*EField") |
| 69 | + edge_model(device="disk", region=region, name="DField:Potential@n0", equation="Permittivity*EField:Potential@n0") |
| 70 | + edge_model(device="disk", region=region, name="DField:Potential@n1", equation="Permittivity*EField:Potential@n1") |
71 | 71 |
|
72 | 72 | #create anions and cations solution variable in solution (positive only applied in equation) |
73 | 73 | node_solution(device="disk", region="solution", name="cations") |
|
89 | 89 |
|
90 | 90 |
|
91 | 91 | for region in ("dna", "dielectric"): |
92 | | - node_model(device="disk", region=region, name="NetCharge", equation="-q*charge_density") |
93 | | - equation(device="disk", region=region, name="PotentialEquation", variable_name="Potential", |
94 | | - node_model="NetCharge", edge_model="DField", variable_update="default") |
| 92 | + node_model(device="disk", region=region, name="NetCharge", equation="-q*charge_density") |
| 93 | + equation(device="disk", region=region, name="PotentialEquation", variable_name="Potential", |
| 94 | + node_model="NetCharge", edge_model="DField", variable_update="default") |
95 | 95 |
|
96 | 96 | #create fluxes in solution |
97 | 97 | # This is complicated, but the Bernoulli functions are a representation of Sharfetter Gummel |
|
117 | 117 |
|
118 | 118 | #derivatives w.r.t. the solution variables |
119 | 119 | for v in ("Potential@n0", "Potential@n1", "anions@n0", "anions@n1", "cations@n0", "cations@n1"): |
120 | | - edge_model(device="disk", region="solution", name="AnionFlux:{0}".format(v), equation="simplify(diff({0},{1}))".format(Ja, v)) |
121 | | - edge_model(device="disk", region="solution", name="CationFlux:{0}".format(v), equation="simplify(diff({0},{1}))".format(Jc, v)) |
| 120 | + edge_model(device="disk", region="solution", name="AnionFlux:{0}".format(v), equation="simplify(diff({0},{1}))".format(Ja, v)) |
| 121 | + edge_model(device="disk", region="solution", name="CationFlux:{0}".format(v), equation="simplify(diff({0},{1}))".format(Jc, v)) |
122 | 122 |
|
123 | 123 | #create continuity equations in solution |
124 | 124 | equation(device="disk", region="solution", name="AnionContinuityEquation", variable_name="anions", |
|
129 | 129 |
|
130 | 130 | #create n0, and potential boundary condition at contact |
131 | 131 | for contact in ("top", "bot"): |
132 | | - node_model(device="disk", region="solution", name="{0}_potential".format(contact), equation="Potential - {0}_bias".format(contact)) |
133 | | - node_model(device="disk", region="solution", name="{0}_potential:Potential".format(contact), equation="1") |
| 132 | + node_model(device="disk", region="solution", name="{0}_potential".format(contact), equation="Potential - {0}_bias".format(contact)) |
| 133 | + node_model(device="disk", region="solution", name="{0}_potential:Potential".format(contact), equation="1") |
134 | 134 |
|
135 | | - contact_equation(device="disk", contact=contact, name="PotentialEquation", variable_name="Potential", |
136 | | - node_model="{0}_potential".format(contact), edge_charge_model="DField") |
| 135 | + contact_equation(device="disk", contact=contact, name="PotentialEquation", variable_name="Potential", |
| 136 | + node_model="{0}_potential".format(contact), edge_charge_model="DField") |
137 | 137 |
|
138 | | - contact_node_model(device="disk", contact=contact, name="{0}_anion".format(contact), equation="anions - n_bound") |
139 | | - contact_node_model(device="disk", contact=contact, name="{0}_anion:anions".format(contact), equation="1") |
140 | | - contact_equation(device="disk", contact=contact, name="AnionContinuityEquation", variable_name="anions", node_model="{0}_anion".format(contact)) |
| 138 | + contact_node_model(device="disk", contact=contact, name="{0}_anion".format(contact), equation="anions - n_bound") |
| 139 | + contact_node_model(device="disk", contact=contact, name="{0}_anion:anions".format(contact), equation="1") |
| 140 | + contact_equation(device="disk", contact=contact, name="AnionContinuityEquation", variable_name="anions", node_model="{0}_anion".format(contact)) |
141 | 141 |
|
142 | | - contact_node_model(device="disk", contact=contact, name="{0}_cation".format(contact), equation="cations - n_bound") |
143 | | - contact_node_model(device="disk", contact=contact, name="{0}_cation:cations".format(contact), equation="1") |
144 | | - contact_equation(device="disk", contact=contact, name="CationContinuityEquation", variable_name="cations", node_model="{0}_cation".format(contact)) |
| 142 | + contact_node_model(device="disk", contact=contact, name="{0}_cation".format(contact), equation="cations - n_bound") |
| 143 | + contact_node_model(device="disk", contact=contact, name="{0}_cation:cations".format(contact), equation="1") |
| 144 | + contact_equation(device="disk", contact=contact, name="CationContinuityEquation", variable_name="cations", node_model="{0}_cation".format(contact)) |
145 | 145 |
|
146 | 146 |
|
147 | 147 | #create potential continuity at interfaces |
148 | 148 | for interface in ("dna_solution", "dielectric_solution"): |
149 | | - interface_model(device="disk", interface=interface, name="continuousPotential", equation="Potential@r0-Potential@r1") |
150 | | - interface_model(device="disk", interface=interface, name="continuousPotential:Potential@r0", equation="1") |
151 | | - interface_model(device="disk", interface=interface, name="continuousPotential:Potential@r1", equation="-1") |
152 | | - interface_equation(device="disk", interface=interface, name="PotentialEquation", variable_name="Potential", interface_model="continuousPotential", type="continuous") |
| 149 | + interface_model(device="disk", interface=interface, name="continuousPotential", equation="Potential@r0-Potential@r1") |
| 150 | + interface_model(device="disk", interface=interface, name="continuousPotential:Potential@r0", equation="1") |
| 151 | + interface_model(device="disk", interface=interface, name="continuousPotential:Potential@r1", equation="-1") |
| 152 | + interface_equation(device="disk", interface=interface, name="PotentialEquation", variable_name="Potential", interface_model="continuousPotential", type="continuous") |
153 | 153 |
|
154 | 154 | # For visualization |
155 | 155 | for region in ("dna", "dielectric", "solution"): |
156 | | - element_from_edge_model(edge_model="EField", device="disk", region=region) |
| 156 | + element_from_edge_model(edge_model="EField", device="disk", region=region) |
157 | 157 | element_from_edge_model(edge_model="AnionFlux", device="disk", region="solution") |
158 | 158 | element_from_edge_model(edge_model="CationFlux", device="disk", region="solution") |
159 | 159 |
|
|
0 commit comments