Still not working, but will be fixed

I have the solution in the plasma expansion code, but I need to do other
stuff.
This commit is contained in:
Jorge Gonzalez 2024-09-30 17:06:25 +02:00
commit 98ee3e9c9c
2 changed files with 26 additions and 27 deletions

View file

@ -108,7 +108,8 @@ MODULE moduleInject
CASE ("A") CASE ("A")
!Input current in Ampers !Input current in Ampers
self%nParticles = INT(flow*tauInject*ti_ref/(qe*species(sp)%obj%weight)) ! TODO: Make this only available for charge species
self%nParticles = INT(flow*tauInject*ti_ref/(qe*abs(species(sp)%obj%qm*species(sp)%obj%m)*species(sp)%obj%weight))
CASE ("part/s") CASE ("part/s")
!Input current in Ampers !Input current in Ampers

View file

@ -46,7 +46,7 @@ MODULE moduleEM
END DO END DO
END SUBROUTINE END SUBROUTINE apply
!Assemble the source vector based on the charge density to solve Poisson's equation !Assemble the source vector based on the charge density to solve Poisson's equation
SUBROUTINE assembleSourceVector(vectorF, n_e) SUBROUTINE assembleSourceVector(vectorF, n_e)
@ -169,25 +169,16 @@ MODULE moduleEM
INTEGER, INTENT(in):: n INTEGER, INTENT(in):: n
REAL(8), INTENT(in):: phi(1:n) REAL(8), INTENT(in):: phi(1:n)
REAL(8):: n_e(1:n) REAL(8):: n_e(1:n)
REAL(8):: n_e0 = 1.0D16, phi_0 = -520.0D0, T_e = 11604.0 REAL(8):: n_e0 = 1.0D16, phi_0 = -500.0D0, T_e = 11604.0
INTEGER:: i INTEGER:: i
DO i =1, n n_e = n_e0 / n_ref * exp(qe * (phi*Volt_ref - phi_0) / (kb * T_e))
IF (phi(i)*Volt_ref >= phi_0) THEN
n_e(i) = n_e0 / n_ref * EXP(-qe * (phi(i)*Volt_ref - phi_0) / (kb * T_e))
ELSE
n_e(i) = 0.D0
END IF
END DO
RETURN RETURN
END FUNCTION BoltzmannElectron END FUNCTION BoltzmannElectron
SUBROUTINE solveElecFieldBoltzmann SUBROUTINE solveElecFieldBoltzmann()
USE moduleMesh USE moduleMesh
USE moduleErrors USE moduleErrors
IMPLICIT NONE IMPLICIT NONE
@ -195,7 +186,7 @@ MODULE moduleEM
INTEGER, SAVE:: INFO INTEGER, SAVE:: INFO
INTEGER:: n INTEGER:: n
REAL(8), ALLOCATABLE, SAVE:: tempF(:) REAL(8), ALLOCATABLE, SAVE:: tempF(:)
REAL(8), ALLOCATABLE, SAVE:: n_e(:), phi_old(:) REAL(8), ALLOCATABLE, SAVE:: n_e(:), phi_old(:), phi(:)
INTEGER:: k INTEGER:: k
EXTERNAL:: dgetrs EXTERNAL:: dgetrs
@ -203,22 +194,29 @@ MODULE moduleEM
ALLOCATE(tempF(1:mesh%numNodes)) ALLOCATE(tempF(1:mesh%numNodes))
ALLOCATE(n_e(1:mesh%numNodes)) ALLOCATE(n_e(1:mesh%numNodes))
ALLOCATE(phi_old(1:mesh%numNodes)) ALLOCATE(phi_old(1:mesh%numNodes))
n_e = 0.D0 ALLOCATE(phi(1:mesh%numNodes))
CALL assembleSourceVector(tempF, n_e)
!$OMP END SINGLE !$OMP END SINGLE
!$OMP DO
DO n = 1, mesh%numNodes
phi_old(n) = mesh%nodes(n)%obj%emData%phi
END DO
!$OMP END DO
!$OMP SINGLE !$OMP SINGLE
DO k = 1, 10 DO k = 1, 100
phi_old = tempF n_e = BoltzmannElectron(phi_old, mesh%numNodes)
CALL assembleSourceVector(tempF, n_e)
CALL dgetrs('N', mesh%numNodes, 1, mesh%K, mesh%numNodes, & CALL dgetrs('N', mesh%numNodes, 1, mesh%K, mesh%numNodes, &
mesh%IPIV, tempF, mesh%numNodes, info) mesh%IPIV, tempF, mesh%numNodes, info)
phi = tempF
PRINT *, MAXVAL(n_e), MINVAL(n_e) PRINT *, MAXVAL(n_e), MINVAL(n_e)
PRINT *, MAXVAL(tempF), MINVAL(tempF) PRINT *, MAXVAL(phi), MINVAL(phi)
PRINT*, k, "diff = ", MAXVAL(ABS(tempF - phi_old)) PRINT*, k, "diff = ", MAXVAL(ABS(phi - phi_old))
n_e = BoltzmannElectron(tempF, mesh%numNodes) phi_old = phi
CALL assembleSourceVector(tempF, n_e)
END DO END DO
!$OMP END SINGLE !$OMP END SINGLE
@ -227,7 +225,7 @@ MODULE moduleEM
!Suscessful resolution of Poission equation !Suscessful resolution of Poission equation
!$OMP DO !$OMP DO
DO n = 1, mesh%numNodes DO n = 1, mesh%numNodes
mesh%nodes(n)%obj%emData%phi = tempF(n) mesh%nodes(n)%obj%emData%phi = phi_old(n)
END DO END DO
!$OMP END DO !$OMP END DO
@ -240,7 +238,7 @@ MODULE moduleEM
END IF END IF
!$OMP SINGLE !$OMP SINGLE
DEALLOCATE(tempF, n_e, phi_old) DEALLOCATE(tempF, n_e, phi_old, phi)
!$OMP END SINGLE !$OMP END SINGLE
END SUBROUTINE solveElecFieldBoltzmann END SUBROUTINE solveElecFieldBoltzmann