Skip to content

Commit 91e52df

Browse files
Added sphere-rod electrode
1 parent 35c0aea commit 91e52df

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

src/m_field.f90

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ subroutine field_initialize(tree, cfg, mg)
226226

227227
electrode_type = "rod"
228228
call CFG_add_get(cfg, "field_electrode_type", electrode_type, &
229-
"Type of electrode (sphere, rod, rod_cone_top, rod_rod, user)")
229+
"Electrode: sphere, rod, rod_cone_top, rod_rod, sphere_rod, user")
230230
!< [electrode_settings]
231231

232232
if (associated(user_potential_bc)) then
@@ -292,6 +292,19 @@ subroutine field_initialize(tree, cfg, mg)
292292

293293
! Provide a function to set the voltage on the electrodes
294294
mg%lsf_boundary_function => rod_rod_get_potential
295+
case ("sphere_rod")
296+
! Sphere and rod electrode with semi-spherical cap
297+
call check_general_electrode_parameters()
298+
299+
if (any(rod2_r0 <= -1.0e10_dp)) &
300+
error stop "field_rod2_r0 not set correctly"
301+
if (any(rod2_r1 <= -1.0e10_dp)) &
302+
error stop "field_rod2_r1 not set correctly"
303+
if (rod2_radius <= 0) &
304+
error stop "field_rod2_radius not set correctly"
305+
306+
mg%lsf => sphere_rod_lsf
307+
mg%lsf_boundary_function => sphere_rod_get_potential
295308
case ("two_rod_cone_electrodes")
296309
! Two rod-shaped electrodes with conical tops (for now assumed to have
297310
! the same shape)
@@ -759,6 +772,41 @@ function rod_rod_get_potential(r) result(phi)
759772
end if
760773
end function rod_rod_get_potential
761774

775+
!> Get level set function for case of sphere and rod
776+
real(dp) function sphere_rod_lsf(r)
777+
use m_geometry
778+
real(dp), intent(in) :: r(NDIM)
779+
780+
sphere_rod_lsf = min(sphere_lsf(r), &
781+
GM_dist_line(r, rod2_r0, rod2_r1, NDIM) - rod2_radius)
782+
end function sphere_rod_lsf
783+
784+
!> Get potential to apply at electrode for sphere-rod case
785+
function sphere_rod_get_potential(r) result(phi)
786+
use m_geometry
787+
real(dp), intent(in) :: r(NDIM)
788+
real(dp) :: phi, lsf_1, lsf_2
789+
790+
! Determine distance to electrodes
791+
lsf_1 = sphere_lsf(r)
792+
lsf_2 = GM_dist_line(r, rod2_r0, rod2_r1, NDIM) - rod2_radius
793+
794+
if (lsf_1 < lsf_2) then
795+
! Closer to electrode 1
796+
if (field_electrode_grounded) then
797+
phi = 0.0_dp
798+
else
799+
phi = current_voltage
800+
end if
801+
else
802+
if (field_electrode2_grounded) then
803+
phi = 0.0_dp
804+
else
805+
phi = current_voltage
806+
end if
807+
end if
808+
end function sphere_rod_get_potential
809+
762810
!> Compute total field energy in Joule, defined as the volume integral over
763811
!> 1/2 * epsilon * E^2
764812
subroutine field_compute_energy(tree, field_energy)

0 commit comments

Comments
 (0)