13 use in_out
, only: save_integration_header,save_integration_step,&
14 save_integration_close
15 use model
, only:odesystem,dim_var,molar_balance
16 use phys_prop
, only:set_initial_physical_properties
20 integer :: meth, itmeth, iatol, jpretype, igstype, maxl, ier
21 integer(c_long) :: ipar(1), mu, ml, iouts(25), maxtss
22 real(dp) :: rout(10), rpar(1), delt
24 integer :: iout, iopt, istate, itask, itol, liw, lrw, nnz, lenrat, neq, mf
25 real(dp) :: jac,tout,rtol,atol,t
26 real(dp),
dimension(:),
allocatable :: rwork
27 integer,
dimension(:),
allocatable :: iwork
30 subroutine sub (neq, t, y, ydot)
32 integer,
intent(in) :: neq
33 real(dp),
intent(in) :: t
34 real(dp),
intent(in) ::
y(neq)
35 real(dp),
intent(out) :: ydot(neq)
38 procedure(sub),
pointer :: sub_ptr => odesystem
39 public bblpreproc,bblinteg,neq
46 write(*,*)
'preparing simulation...' 48 call set_initial_physical_properties
49 call set_equation_order
51 call set_initial_conditions
53 write(*,*)
'done: simulation prepared' 55 end subroutine bblpreproc
70 stop
'unknown kinetic model' 73 print*,
'geometry can be 3D or 2D' 85 subroutine create_mesh(a,b,p,s)
86 integer,
intent(in) :: p
87 real(dp),
intent(in) :: &
92 real(dp),
allocatable :: atri(:),btri(:),ctri(:),rtri(:),utri(:)
93 allocate(atri(p),btri(p),ctri(p),rtri(p),utri(p),
dz(p+1))
100 call dgtsl(p,atri,btri,ctri,utri,info)
101 if ((utri(2)-utri(1))/utri(1)<10*epsilon(utri)) stop
'set smaller mesh & 102 coarsening parameter' 103 dz(1)=utri(1)+rtri(1)/s
105 dz(i)=utri(i)-utri(i-1)
107 dz(p+1)=rtri(p)-utri(p)
108 deallocate(atri,btri,ctri,rtri,utri)
109 end subroutine create_mesh
118 subroutine set_equation_order
148 end subroutine set_equation_order
156 subroutine set_integrator
163 allocate(rwork(20+16*neq),iwork(20))
165 allocate(rwork(22+9*neq+neq**2),iwork(20+neq))
172 allocate(rwork(20+16*neq),iwork(30))
176 allocate(rwork(int(20+(2+1._dp/lenrat)*nnz+(11+9._dp/lenrat)*neq)),&
182 stop
'unknown integrator' 187 rwork(1)=tend+epsilon(tend)*1.0e3_dp
208 call fnvinits(1, neq, ier)
210 write(*,*)
' sundials_error: fnvinits returned ier = ',ier
214 call fcvmalloc(t,
y, meth, itmeth, iatol, rtol, atol,&
215 iouts, rout, ipar, rpar, ier)
217 write(*,*)
' sundials_error: fcvmalloc returned ier = ',ier
221 call fcvsetiin(
"MAX_NSTEPS",
maxts,ier)
223 write(*,*)
' sundials_error: fcvsetiin returned ier = ',ier
227 call fcvspgmr(jpretype, igstype, maxl, delt, ier)
229 write(*,*)
' sundials_error: fcvspgmr returned ier = ',ier
248 call fcvbpinit(neq, mu, ml, ier)
250 write(*,*)
' sundials_error: fcvbpinit returned ier = ',ier
254 end subroutine set_integrator
262 subroutine set_initial_conditions
293 if (
y(
fpeq+i-1)<1e-16_dp)
y(
fpeq+i-1)=1e-16_dp
295 end subroutine set_initial_conditions
303 subroutine growth_rate
311 end subroutine growth_rate
320 write(*,*)
'integrating...' 322 call save_integration_header
324 call molar_balance(
y)
326 call save_integration_step(0)
331 call dlsode (sub_ptr, neq,
y, t, tout, itol, rtol, atol, itask, &
332 istate, iopt, rwork, lrw, iwork, liw, jac, mf)
334 call dlsodes (sub_ptr, neq,
y, t, tout, itol, rtol, atol, itask, &
335 istate, iopt, rwork, lrw, iwork, liw, jac, mf)
337 call fcvode(tout, t,
y, itask, ier)
339 write(*,*)
' sundials_error: fcvode returned ier = ',ier
340 write(*,*)
' linear solver returned ier = ',iouts(15)
345 stop
'unknown integrator' 348 call molar_balance(
y)
350 if (firstrun)
call save_integration_step(iout)
352 write(*,
'(2x,A4,F8.3,A3,A13,F10.3,A4,A19,F8.3,A3)') &
353 't = ',
time,
' s,',&
354 'p_b - p_o = ', bub_pres,
' Pa,', &
359 write(*,
'(2x,A,f7.3,A)')
'gel point reached at time t = ',
time,
' s' 360 write(*,
'(2x,A,f6.1,A)')
'temperature at gel point T = ',
temp,
' K' 361 write(*,
'(2x,A,f5.3)')
'conversion at gel point X = ',
conv 365 if (firstrun)
call save_integration_close(iout)
366 write(*,*)
'done: integration' 367 call destroymodenamodels
368 deallocate(
d,
cbl,
xgas,
kh,
mbl,
dhv,
mb,
mb2,
mb3,
avconc,
pressure,&
370 end subroutine bblinteg
372 end module integration
logical gelpoint
gel point reached (t/f)
real(dp) polyol1_ini
initial concentration of polyol 1
real(dp), dimension(2) nold
moles in bubble
real(dp), dimension(:), allocatable dhv
evaporation heat of blowing agent (for each gas)
integer teq
temperature equation (index)
integer ngas
number of dissolved gases
integer, dimension(:), allocatable sol_model
solubility model 1=constant,2=modena
real(dp) temp
temperature (K)
real(dp), dimension(:), allocatable y
state variables
real(dp) amine_ini
initial concentration of amine
integer req
radius equation (index)
real(dp) radius
bubble radius (m)
real(dp), dimension(:), allocatable kh
Henry constants (for each dissolved gas)
real(dp), dimension(:), allocatable mb2
moles in bubble
real(dp) rel_tol
relative tolerance
real(dp) w0
initial concentration of water (can be zero)
real(dp) isocyanate2_ini
initial concentration of isocyanate 2
real(dp), dimension(:), allocatable dz
spatial discretization
real(dp), dimension(:), allocatable pressure
partial pressure(Pa)
real(dp), dimension(:), allocatable kinsource
kinetic source term
real(dp) s0
initial shell thickness
real(dp) laplace_pres
Laplace pressure (Pa)
logical inertial_term
include inertial term in equations (t/f)
real(dp) sigma
interfacial tension
integer, dimension(:), allocatable diff_model
diffusivity model 1=constant,2=modena
real(dp) isocyanate3_ini
initial concentration of isocyanate 3
real(dp), dimension(:), allocatable mbl
blowing agent molar mass (for each dissolved gas)
real(dp) conv
conversion of polyol
character(len=99) geometry
geometry 3D=spherical, 2D=cylindrical
integer, dimension(:), allocatable kineq
kinetics state variable equations (indexes)
subroutine dgtsl(n, c, d, e, b, info)
real(dp) abs_tol
absolute tolerance
real(dp), dimension(:), allocatable cpbll
heat capacity of blowing agent in liquid phase (for each gas)
real(dp), dimension(:), allocatable d0
initial diffusion coefficients used in non-dimensional routines
real(dp) mshco
mesh coarsening parameter
real(dp), dimension(:), allocatable mb3
total moles
integer lpeq
last pressure equation (index)
real(dp), dimension(:), allocatable xgas
initial molar fraction of gases in the bubble
real(dp), dimension(:), allocatable cbl
concentration profile in reaction mixture
integer integrator
integrator. 1=dlsode,2=dlsodes
real(dp), dimension(:), allocatable d
diffusion coefficients (for each dissolved gas)
real(dp), dimension(:), allocatable avconc
average concentration in reaction mixture
real(dp), dimension(:), allocatable mb
moles in polymer
real(dp) pamb
ambient pressure (in the liquid)
real(dp) polyol2_ini
initial concentration of polyol 2
integer kin_model
reaction kinetics model.
real(dp) timestep
timestep
real(dp), dimension(:), allocatable wblpol
weight fraction of blowing agents in reaction mixture
integer its
number of outer integration outer time steps
integer fceq
first concentration equation (index)
integer xoheq
polyol conversion equation (index)
real(dp), dimension(2) grrate
growth rate
real(dp) isocyanate1_ini
initial concentration of isocyanate 1
real(dp) r0
initial radius
integer fpeq
first pressure equation (index)
namespace with global variables
integer p
number of internal nodes
integer maxts
maximum inner time steps between t and t+h
real(dp), dimension(:), allocatable cpblg
heat capacity of blowing agent in gas phase (for each gas)
real(dp) catalyst
concentration of catalyst
integer xweq
water conversion equation (index)
integer int_meth
stiff or no? See MF for ODEPACK