Skip to content

Commit 387b664

Browse files
committed
Fix φ-handling in get_electric_field_from_potential
1 parent 890568c commit 387b664

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎src/ElectricField/ElectricField.jl‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ function get_electric_field_from_potential(epot::ElectricPotential{T, 3, Cylindr
129129
er *= 2
130130
end
131131
end
132-
if (1 < iφ < size(point_types, 2))
133-
if (point_types[ir, iφ - 1, iz] & update_bit > 0) && (point_types[ir, iφ + 1, iz] & update_bit > 0)
134-
if (point_types[ir, iφ - 1, iz] & pn_junction_bit > 0) && (point_types[ir, iφ + 1, iz] & pn_junction_bit == 0)
132+
let iφL = iφ == 1 ? size(point_types, 2) : iφ - 1, iφR = iφ == size(point_types,2) ? 1 : iφ + 1
133+
if (point_types[ir, iφL, iz] & update_bit > 0) && (point_types[ir, iφR, iz] & update_bit > 0)
134+
if (point_types[ir, iφL, iz] & pn_junction_bit > 0) && (point_types[ir, iφR, iz] & pn_junction_bit == 0)
135135
eφ = Δp_φ_2 / d_φ_2
136-
elseif (point_types[ir, iφ + 1, iz] & pn_junction_bit > 0) && (point_types[ir, iφ - 1, iz] & pn_junction_bit == 0)
136+
elseif (point_types[ir, iφR, iz] & pn_junction_bit > 0) && (point_types[ir, iφL, iz] & pn_junction_bit == 0)
137137
eφ = Δp_φ_1 / d_φ_1
138138
end
139-
elseif (point_types[ir, iφ - 1, iz] & update_bit > 0) || (point_types[ir, iφ + 1, iz] & update_bit > 0)
139+
elseif (point_types[ir, iφL, iz] & update_bit > 0) || (point_types[ir, iφR, iz] & update_bit > 0)
140140
eφ *= 2
141141
end
142142
end

0 commit comments

Comments
 (0)