It seems to work, but I don't think this is quite useful for the manuscript

This commit is contained in:
Jorge Gonzalez 2026-04-08 15:17:30 +02:00
commit eb10ae92a6
4 changed files with 71 additions and 12 deletions

View file

@ -127,14 +127,15 @@ submodule(moduleMesh) boundaryEM
! Init
module subroutine initFloating(self, config, object)
use json_module
use moduleRefParam, only: Volt_ref
use moduleRefParam, only: Volt_ref, L_ref
use moduleConstParam, only: eps_0
use moduleErrors
implicit none
class(boundaryEMGeneric), allocatable, intent(inout):: self
type(json_file), intent(inout):: config
character(:), allocatable, intent(in):: object
real(8):: potential
real(8):: potential, capacitance
logical:: found
select type(self)
@ -148,8 +149,20 @@ submodule(moduleMesh) boundaryEM
self%potential = potential / Volt_ref
call config%get(object // '.capacitance', capacitance, found)
if (.not. found) then
call warningError('Parameter "capacitance" for floating boundary condition not found. Using the default value of 1 nF.')
capacitance = 1.0d-9
end if
! Inverse of non-dimensional capacitance
self%invC = 1.0d0 / (capacitance / (eps_0 * L_ref))
self%update => updateFloating
allocate(self%edges(0))
end select
end subroutine initFloating
@ -174,40 +187,60 @@ submodule(moduleMesh) boundaryEM
! Update
subroutine updateFloating(self)
use moduleMesh, only: qSpecies, meshNode
use moduleCaseParam, only: tauMin
implicit none
class(boundaryEMGeneric), intent(inout):: self
integer:: n, s
integer:: e, n, s
integer, allocatable:: nodes(:)
class(meshEdge), pointer:: edge
real(8), allocatable:: mom_nodes(:)
class(meshNode), pointer:: node
real(8):: momNode, momNodeTotal, totalCurrent
real(8):: mom_center, edgeDensityCurrent, totalCurrent
totalCurrent = 0.0d0
select type(self)
type is(boundaryEMFloating)
do n = 1, self%nNodes
momNodeTotal = 0.0d0
do e = 1, size(self%edges)
edge => self%edges(e)%obj
node => self%nodes(n)%obj
edgeDensityCurrent = 0.0d0
nodes = edge%getNodes(edge%nNodes)
allocate(mom_nodes(1:edge%nNodes))
do s = 1, nSpecies
print *, s, node%output(s)%mom
momNode = norm2(node%output(s)%mom)
mom_center = 0.0d0
do n = 1, self%nNodes
node => mesh%nodes(nodes(n))%obj
momNodeTotal = momNodeTotal + qSpecies(s) * momNode
! Minus sign to get the flux exiting the edge
mom_nodes(n) = - dot_product(node%output(s)%mom, edge%normal)
end do
mom_center = edge%gatherF(edge%centerXi(), edge%nNodes, mom_nodes)
edgeDensityCurrent = edgeDensityCurrent + qSpecies(s) * mom_center
end do
totalCurrent = totalCurrent + momNodeTotal
totalCurrent = totalCurrent + edgeDensityCurrent * edge%surface
end do
print *, totalCurrent
self%potential = self%potential + self%invC * totalCurrent * tauMin
! print *, totalCurrent, self%potential
end select
end subroutine updateFloating
! Write
subroutine writeFloating()
end subroutine writeFloating
! Get the index of the boundary based on the name
module function boundaryEMName_to_Index(boundaryName) result(bp)
use moduleErrors