From e5519cee2d9f8811d6917c162621dfa780d5541b Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Mon, 13 Apr 2026 14:54:40 +0200 Subject: [PATCH 1/4] Deleted the constraing of flux > 0 --- src/modules/mesh/moduleMesh@boundaryEM.f90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/modules/mesh/moduleMesh@boundaryEM.f90 b/src/modules/mesh/moduleMesh@boundaryEM.f90 index 26363b5..f20804a 100644 --- a/src/modules/mesh/moduleMesh@boundaryEM.f90 +++ b/src/modules/mesh/moduleMesh@boundaryEM.f90 @@ -224,9 +224,6 @@ submodule(moduleMesh) boundaryEM mom_center = edge%gatherF(edge%centerXi(), edge%nNodes, mom_nodes) - ! Only account for charge exiting the surface - mom_center = max(mom_center, 0.0d0) - edgeDensityCurrent = edgeDensityCurrent + qSpecies(s) * mom_center end do From 4da3bf120cea62171e1777b764aed99e93b4c934 Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Mon, 13 Apr 2026 19:49:53 +0200 Subject: [PATCH 2/4] Structure for Neumann BC --- src/modules/mesh/moduleMesh.f90 | 27 ++++++++++++++++++++++ src/modules/mesh/moduleMesh@boundaryEM.f90 | 21 +++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/modules/mesh/moduleMesh.f90 b/src/modules/mesh/moduleMesh.f90 index e257cf2..5fc6f2e 100644 --- a/src/modules/mesh/moduleMesh.f90 +++ b/src/modules/mesh/moduleMesh.f90 @@ -1056,6 +1056,33 @@ MODULE moduleMesh end interface + ! Neumann boundary condition (constant electric field normal to edge) + type, extends(boundaryEMGeneric):: boundaryEMNeumann + real(8):: electricField ! Electric field normal to the edge + contains + ! boundaryEMGeneric deferred procedures + procedure, pass:: apply => applyNeumann + + end type boundaryEMNeumann + + interface + module subroutine initNeumann(self, config, object) + use json_module + + class(boundaryEMGeneric), allocatable, intent(inout):: self + type(json_file), intent(inout):: config + character(:), allocatable, intent(in):: object + + end subroutine initNeumann + + module subroutine applyNeumann(self, vectorF) + class(boundaryEMNeumann), intent(in):: self + real(8), intent(inout):: vectorF(:) + + end subroutine applyNeumann + + end interface + ! Floating: Floating surface, ie, zero net current type, extends(boundaryEMGeneric):: boundaryEMFloating real(8):: potential diff --git a/src/modules/mesh/moduleMesh@boundaryEM.f90 b/src/modules/mesh/moduleMesh@boundaryEM.f90 index f20804a..19dde6c 100644 --- a/src/modules/mesh/moduleMesh@boundaryEM.f90 +++ b/src/modules/mesh/moduleMesh@boundaryEM.f90 @@ -123,6 +123,27 @@ submodule(moduleMesh) boundaryEM end subroutine updateDirichletTime + ! Neumann constant value + ! Init + module subroutine initNeumann(self, config, object) + use json_module + implicit none + + class(boundaryEMGeneric), allocatable, intent(inout):: self + type(json_file), intent(inout):: config + character(:), allocatable, intent(in):: object + + end subroutine initNeumann + + ! Apply + module subroutine applyNeumann(self, vectorF) + implicit none + + class(boundaryEMNeumann), intent(in):: self + real(8), intent(inout):: vectorF(:) + + end subroutine applyNeumann + ! Floating surface ! Init module subroutine initFloating(self, config, object) From e06ce499da1323a32075447478b660e28f2eebeb Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Tue, 14 Apr 2026 10:37:16 +0200 Subject: [PATCH 3/4] Functions done --- src/modules/mesh/moduleMesh@boundaryEM.f90 | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/modules/mesh/moduleMesh@boundaryEM.f90 b/src/modules/mesh/moduleMesh@boundaryEM.f90 index 19dde6c..891e34b 100644 --- a/src/modules/mesh/moduleMesh@boundaryEM.f90 +++ b/src/modules/mesh/moduleMesh@boundaryEM.f90 @@ -30,7 +30,6 @@ submodule(moduleMesh) boundaryEM ! Apply module SUBROUTINE applyDirichlet(self, vectorF) - USE moduleMesh IMPLICIT NONE CLASS(boundaryEMDirichlet), INTENT(in):: self @@ -38,8 +37,11 @@ submodule(moduleMesh) boundaryEM integer:: n DO n = 1, self%nNodes - self%nodes(n)%obj%emData%phi = self%potential - vectorF(self%nodes(n)%obj%n) = self%nodes(n)%obj%emData%phi + associate(node => self%nodes(n)%obj) + node%emData%phi = self%potential + vectorF(node%n) = node%emData%phi + + end associate END DO @@ -127,11 +129,27 @@ submodule(moduleMesh) boundaryEM ! Init module subroutine initNeumann(self, config, object) use json_module + use moduleRefParam, only: EF_ref + use moduleErrors, only: criticalError implicit none class(boundaryEMGeneric), allocatable, intent(inout):: self type(json_file), intent(inout):: config character(:), allocatable, intent(in):: object + real(8):: electricField + logical:: found + + select type(self) + type is(boundaryEMNeumann) + call config%get(object // '.electricField', electricField, found) + if (.not. found) then + call criticalError('Required parameter "electricField" for Neumann boundary condition not found', 'readBoundaryEM') + + end if + + self%electricField = electricField / EF_ref + + end select end subroutine initNeumann @@ -141,6 +159,15 @@ submodule(moduleMesh) boundaryEM class(boundaryEMNeumann), intent(in):: self real(8), intent(inout):: vectorF(:) + integer:: n + + do n = 1, self%nNodes + associate(node => self%nodes(n)%obj) + vectorF(node%n) = vectorF(node%n) + self%electricField + + end associate + + end do end subroutine applyNeumann From 3275ccc3c221a5ef60450cecd3eca61064a3f0ec Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Tue, 14 Apr 2026 10:40:21 +0200 Subject: [PATCH 4/4] Input done --- src/modules/init/moduleInput.f90 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/init/moduleInput.f90 b/src/modules/init/moduleInput.f90 index 19a4369..8ab443f 100644 --- a/src/modules/init/moduleInput.f90 +++ b/src/modules/init/moduleInput.f90 @@ -979,6 +979,11 @@ MODULE moduleInput call initDirichletTime(self, config, object) + case ("neumann") + allocate(boundaryEMNeumann:: self) + + call initNeumann(self, config, object) + case ("floating") allocate(boundaryEMFloating:: self)