Change boundary file module

This commit is contained in:
JHendrikx 2025-02-19 12:09:35 +01:00
commit d13146a31c
2 changed files with 8 additions and 17 deletions

View file

@ -6,10 +6,9 @@ module moduleTableBC
real(dp):: n_min, n_max real(dp):: n_min, n_max
real(dp):: u_min, u_max real(dp):: u_min, u_max
real(dp):: Temp_min, Temp_max real(dp):: Temp_min, Temp_max
real(dp):: Zave_min, Zave_max
real(dp), allocatable, dimension(:):: t real(dp), allocatable, dimension(:):: t
real(dp), allocatable, dimension(:):: n, u, Temp, Zave real(dp), allocatable, dimension(:):: n, u, Temp
real(dp), allocatable, dimension(:):: n_k, u_k, Temp_k, Zave_k real(dp), allocatable, dimension(:):: n_k, u_k, Temp_k
contains contains
procedure, pass:: init => initTableBC procedure, pass:: init => initTableBC
procedure, pass:: get => getValueTableBC procedure, pass:: get => getValueTableBC
@ -48,17 +47,15 @@ module moduleTableBC
!Allocate table arrays !Allocate table arrays
allocate(self%t(1:amount)) allocate(self%t(1:amount))
allocate( self%n(1:amount), self%u(1:amount), self%Temp(1:amount), self%Zave(1:amount)) allocate( self%n(1:amount), self%u(1:amount), self%Temp(1:amount))
allocate(self%n_k(1:amount), self%u_k(1:amount), self%Temp_k(1:amount), self%Zave_k(1:amount)) allocate(self%n_k(1:amount), self%u_k(1:amount), self%Temp_k(1:amount))
self%t = 0.0_dp self%t = 0.0_dp
self%n = 0.0_dp self%n = 0.0_dp
self%u = 0.0_dp self%u = 0.0_dp
self%Temp = 0.0_dp self%Temp = 0.0_dp
self%Zave = 0.0_dp
self%n_k = 0.0_dp self%n_k = 0.0_dp
self%u_k = 0.0_dp self%u_k = 0.0_dp
self%Temp_k = 0.0_dp self%Temp_k = 0.0_dp
self%Zave_k = 0.0_dp
i = 0 i = 0
read(id, *) ! Skip header read(id, *) ! Skip header
@ -70,7 +67,7 @@ module moduleTableBC
!TODO: substitute with extracting information from dummy !TODO: substitute with extracting information from dummy
backspace(id) backspace(id)
i = i + 1 i = i + 1
read(id, *) self%t(i), self%n(i), self%u(i), self%Temp(i), self%Zave(i) read(id, *) self%t(i), self%n(i), self%u(i), self%Temp(i)
end do end do
@ -89,25 +86,22 @@ module moduleTableBC
self%u_max = self%u(amount) self%u_max = self%u(amount)
self%Temp_min = self%Temp(1) self%Temp_min = self%Temp(1)
self%Temp_max = self%Temp(amount) self%Temp_max = self%Temp(amount)
self%Zave_min = self%Zave(1)
self%Zave_max = self%Zave(amount)
do i = 1, amount - 1 do i = 1, amount - 1
self%n_k(i) = ( self%n(i+1) - self%n(i))/(self%t(i+1) - self%t(i)) self%n_k(i) = ( self%n(i+1) - self%n(i))/(self%t(i+1) - self%t(i))
self%u_k(i) = ( self%u(i+1) - self%u(i))/(self%t(i+1) - self%t(i)) self%u_k(i) = ( self%u(i+1) - self%u(i))/(self%t(i+1) - self%t(i))
self%Temp_k(i) = (self%Temp(i+1) - self%Temp(i))/(self%t(i+1) - self%t(i)) self%Temp_k(i) = (self%Temp(i+1) - self%Temp(i))/(self%t(i+1) - self%t(i))
self%Zave_k(i) = (self%Zave(i+1) - self%Zave(i))/(self%t(i+1) - self%t(i))
end do end do
end subroutine initTableBC end subroutine initTableBC
subroutine getValueTableBC(self, t, n, u, Temp, Zave) subroutine getValueTableBC(self, t, n, u, Temp)
implicit none implicit none
class(tableBC), intent(in):: self class(tableBC), intent(in):: self
real(dp), intent(in):: t real(dp), intent(in):: t
real(dp), intent(out):: n, u, Temp, Zave real(dp), intent(out):: n, u, Temp
real(dp):: delta_t real(dp):: delta_t
integer:: i integer:: i
@ -115,13 +109,11 @@ module moduleTableBC
n = self%n_min n = self%n_min
u = self%u_min u = self%u_min
Temp = self%Temp_min Temp = self%Temp_min
Zave = self%Zave_min
elseif (t >= self%t_max) THEN elseif (t >= self%t_max) THEN
n = self%n_max n = self%n_max
u = self%u_max u = self%u_max
Temp = self%Temp_max Temp = self%Temp_max
Zave = self%Zave_max
else else
i = minloc(abs(t - self%t), 1) i = minloc(abs(t - self%t), 1)
@ -135,7 +127,6 @@ module moduleTableBC
n = self%n(i) + self%n_k(i)*delta_t n = self%n(i) + self%n_k(i)*delta_t
u = self%u(i) + self%u_k(i)*delta_t u = self%u(i) + self%u_k(i)*delta_t
Temp = self%Temp(i) + self%Temp_k(i)*delta_t Temp = self%Temp(i) + self%Temp_k(i)*delta_t
Zave = self%Zave(i) + self%Zave_k(i)*delta_t
end if end if

View file

@ -235,7 +235,7 @@ program VlaPlEx
! Main loop ! Main loop
do t = 1, nt do t = 1, nt
time = t * dt + t0 time = t * dt + t0
call boundaryConditions%get(time, n_bc, u_bc, Temp_bc, Zave_bc) call boundaryConditions%get(time, n_bc, u_bc, Temp_bc)
z_inj = minloc(abs(Z_list - T_to_Z(Temp_bc)),1) z_inj = minloc(abs(Z_list - T_to_Z(Temp_bc)),1)
Zave_bc = Z_list(z_inj) Zave_bc = Z_list(z_inj)
u_bc = sqrt(Zave_bc * Temp_bc) u_bc = sqrt(Zave_bc * Temp_bc)