SpectraRust/tlusty/extracted/settrm.f
2026-03-19 14:05:33 +08:00

85 lines
2.2 KiB
Fortran

SUBROUTINE SETTRM
C =================
C
C reads the equation-of-state tables for the pressure (P)
C and entropy (S), as a function of T and rho;
C
C stores P(rho,T) and S(rho,t) in arrays PL and SL
C
INCLUDE 'IMPLIC.FOR'
COMMON/THERM/SL(330,100),PL(330,100)
COMMON/TABLTD/R1,R2,T1,T2,T12,T22,INDEX
common/tdedge/redge,pedge(100),sedge(100),cvedge(100),
& cpedge(100),gammaedge(100),tedge(100)
common/tdflag/JON
parameter (RCON=8.31434E7)
C
open(58,file='./data/stab.dat',status='old')
open(59,file='./data/ptab.dat',status='old')
C
READ(58,*) YHEA,INDEX,R1,R2,T1,T2,T12,T22
DO JR = 1,INDEX
DO JQS=1,10
JL = 1 + (JQS-1)*10
JU = JL + 9
READ(58,130) (SL(JR,JQ),JQ=JL,JU)
130 FORMAT(10F8.5)
END DO
END DO
C
READ(59,*) YHEA,INDEX,R1,R2,T1,T2,T12,T22
DO JR=1,INDEX
DO JQP=1,10
JL = 1 + (JQP-1)*10
JU = JL + 9
READ(59,130) (PL(JR,JQ),JQ=JL,JU)
END DO
END DO
C
CLOSE(58)
CLOSE(59)
c
c Edge arrays
c
r = 1.5d0*10.d0**r1
tmin = 1.5d0*10.d0**t1
tmax = 0.9d0*10.d0**t2
redge = r
do i = 1, 100
t = t1 + (t2-t1)*dfloat(i-1)/dfloat(99)
t = 10.d0**t
t = min(tmax,max(t,tmin))
tedge(i) = t
rho=r
CALL PRSENT(RHO*1.1,T,P1,S1)
CALL PRSENT(RHO,T*1.1,P2,S2)
CALL PRSENT(RHO,T,P0,S0)
S1=RCON*S1
S2=RCON*S2
S0=RCON*S0
DPDR=(P1-P0)/(.1*RHO)
DPDT=(P2-P0)/(.1*T)
DSDT=(S2-S0)/(.1*T)
DSDR=(S1-S0)/(.1*RHO)
DEN=DPDR*DSDT-DPDT*DSDR
P=P0
S=S0/RCON
CV=T*DSDT
CP=T*DEN/DPDR
DQ=DSDT*P/(DEN*RHO)
GAMMA=1.d0/DQ
c
pedge(i) = p
sedge(i) = s
cvedge(i) = cv
cpedge(i) = cp
gammaedge(i) = gamma
write(44,45) i,tedge(i),cvedge(i),cpedge(i),sedge(i),
& gammaedge(i)
45 format(i4,5e14.5)
enddo
c
RETURN
END