Time variable Dirichlet condition #52

Merged
JorgeGonz merged 8 commits from feature/temporalDirichlet into development 2024-07-13 13:01:11 +02:00
2 changed files with 21 additions and 11 deletions
Showing only changes of commit 2d4b405fb1 - Show all commits

Functionality added

Now we have a new boundary condition that can change the value of the
potential in a surface based on a file.
Jorge Gonzalez 2024-07-13 12:06:41 +02:00

View file

@ -1137,7 +1137,6 @@ MODULE moduleInput
USE moduleOutput
USE moduleErrors
USE moduleEM
USE moduleRefParam
USE moduleSpecies
USE json_module
IMPLICIT NONE
@ -1148,7 +1147,7 @@ MODULE moduleInput
CHARACTER(:), ALLOCATABLE:: typeEM
REAL(8):: potential
INTEGER:: physicalSurface
CHARACTER(:), ALLOCATABLE:: temporalProfile
CHARACTER(:), ALLOCATABLE:: temporalProfile, temporalProfilePath
INTEGER:: b, s, n, ni
CHARACTER(2):: bString
INTEGER:: info
@ -1156,11 +1155,14 @@ MODULE moduleInput
CALL config%info('boundaryEM', found, n_children = nBoundaryEM)
IF (found) ALLOCATE(boundaryEM(1:nBoundaryEM))
IF (found) THEN
ALLOCATE(boundaryEM(1:nBoundaryEM))
END IF
DO b = 1, nBoundaryEM
WRITE(bString, '(I2)') b
object = 'boundaryEM(' // trim(bString) // ')'
object = 'boundaryEM(' // TRIM(bString) // ')'
CALL config%get(object // '.type', typeEM, found)
@ -1174,7 +1176,8 @@ MODULE moduleInput
CALL config%get(object // '.physicalSurface', physicalSurface, found)
IF (.NOT. found) THEN
CALL criticalError('Required parameter "physicalSurface" for Dirichlet boundary condition not found', 'readEMBoundary')
CALL criticalError('Required parameter "physicalSurface" for Dirichlet boundary condition not found', &
'readEMBoundary')
END IF
@ -1183,23 +1186,27 @@ MODULE moduleInput
CASE ("dirichletTime")
CALL config%get(object // '.potential', potential, found)
IF (.NOT. found) THEN
CALL criticalError('Required parameter "potential" for Dirichlet boundary condition not found', 'readEMBoundary')
CALL criticalError('Required parameter "potential" for Dirichlet Time boundary condition not found', &
'readEMBoundary')
END IF
CALL config%get(object // '.temporalProfile', temporalProfile, found)
IF (.NOT. found) THEN
CALL criticalError('Required parameter "potential" for Dirichlet boundary condition not found', 'readEMBoundary')
CALL criticalError('Required parameter "temporalProfile" for Dirichlet Time boundary condition not found', &
'readEMBoundary')
END IF
temporalProfilePath = path // temporalProfile
CALL config%get(object // '.physicalSurface', physicalSurface, found)
IF (.NOT. found) THEN
CALL criticalError('Required parameter "physicalSurface" for Dirichlet boundary condition not found', 'readEMBoundary')
CALL criticalError('Required parameter "physicalSurface" for Dirichlet Time boundary condition not found', &
'readEMBoundary')
END IF
CALL initDirichletTime(boundaryEM(b)%obj, physicalSurface, potential, temporalProfile)
CALL initDirichletTime(boundaryEM(b)%obj, physicalSurface, potential, temporalProfilePath)
CASE DEFAULT
CALL criticalError('Boundary type ' // typeEM // ' not yet supported', 'readEMBoundary')

View file

@ -109,6 +109,7 @@ MODULE moduleEM
! Point boundary to nodes
nNodes = SIZE(nodes)
ALLOCATE(self%nodes(nNodes))
self%nNodes = nNodes
DO n = 1, nNodes
self%nodes(n)%obj => mesh%nodes(nodes(n))%obj
@ -190,10 +191,13 @@ MODULE moduleEM
CLASS(boundaryEMDirichletTime), INTENT(in):: self
REAL(8), INTENT(inout):: vectorF(:)
REAL(8):: timeFactor
INTEGER:: n, ni
timeFactor = self%temporalProfile%get(DBLE(timeStep)*tauMin)
DO n = 1, self%nNodes
self%nodes(n)%obj%emData%phi = self%potential !TODO: Correct for time
self%nodes(n)%obj%emData%phi = self%potential * timeFactor
vectorF(self%nodes(n)%obj%n) = self%nodes(n)%obj%emData%phi
END DO
@ -274,7 +278,6 @@ MODULE moduleEM
ALLOCATE(tempF(1:mesh%numNodes))
!$OMP END SINGLE
!TODO: Is this done every time step??? Then things are gonna be really simple.
CALL assembleSourceVector(tempF)
!$OMP SINGLE