11 use ioutils
, only:newunit,str
14 public set_paths,read_inputs,save_integration_header,&
15 save_integration_step,save_integration_close,load_old_results
38 end subroutine set_paths
43 subroutine read_inputs
45 use fson_value_m
, only: fson_value_get
46 character(len=1024) :: strval
47 type(fson_value),
pointer :: json_data
48 write(*,*)
'loading input file ',trim(
inputs)
49 json_data => fson_parse(
inputs)
52 call fson_get(json_data,
"bubbleGrowth.geometry",
geometry)
53 call fson_get(json_data,
"bubbleGrowth.integrator", strval)
54 if (strval==
"dlsode")
then 56 elseif (strval==
"dlsodes")
then 58 elseif (strval==
"cvode")
then 61 stop
'unknown integrator' 63 call fson_get(json_data,
"bubbleGrowth.method", strval)
64 if (strval==
"nonstiff")
then 70 elseif (strval==
"stiff")
then 81 stop
'method can be either stiff or nonstiff' 83 call fson_get(json_data,
"bubbleGrowth.inertialTerm",
inertial_term)
84 call fson_get(json_data,
"bubbleGrowth.solubilityCorrection",
solcorr)
85 call fson_get(json_data,
"bubbleGrowth.meshCoarseningParameter",
mshco)
86 call fson_get(json_data,
"bubbleGrowth.internalNodes",
p)
87 call fson_get(json_data,
"bubbleGrowth.initialTime", tstart)
88 if (firstrun .and. .not.
shooting)
then 89 call fson_get(json_data,
"bubbleGrowth.finalTime", tend)
91 call fson_get(json_data,
"bubbleGrowth.outerTimeSteps",
its)
92 call fson_get(json_data,
"bubbleGrowth.maxInnerTimeSteps",
maxts)
93 call fson_get(json_data,
"bubbleGrowth.relativeTolerance",
rel_tol)
94 call fson_get(json_data,
"bubbleGrowth.absoluteTolerance",
abs_tol)
99 call fson_get(json_data,
"physicalProperties.pressure",
pamb)
101 json_data,
"physicalProperties.blowingAgents.PBL.molarMass",
mbl(1))
103 json_data,
"physicalProperties.blowingAgents.CO2.molarMass",
mbl(2))
104 call fson_get(json_data,
"physicalProperties.polymer.heatCapacity",
cppol)
107 "physicalProperties.blowingAgents.PBL.heatCapacityInLiquidPhase", &
111 "physicalProperties.blowingAgents.CO2.heatCapacityInLiquidPhase", &
115 "physicalProperties.blowingAgents.PBL.heatCapacityInGaseousPhase", &
119 "physicalProperties.blowingAgents.CO2.heatCapacityInGaseousPhase", &
123 "physicalProperties.blowingAgents.PBL.evaporationHeat",
dhv(1))
126 "physicalProperties.blowingAgents.CO2.evaporationHeat",
dhv(2))
128 json_data,
"physicalProperties.blowingAgents.PBL.density",
rhobl)
129 call fson_get(json_data,
"initialConditions.temperature",
temp0)
131 call fson_get(json_data,
"initialConditions.bubbleRadius",
r0)
133 call fson_get(json_data,
"initialConditions.numberBubbleDensity",
nb0)
134 call fson_get(json_data,
"kinetics.kineticModel", strval)
135 if (strval==
'Baser')
then 137 elseif (strval==
'BaserRx')
then 139 elseif (strval==
'RF-1')
then 142 stop
'unknown kinetic model' 144 call fson_get(json_data,
"initialConditions.concentrations.water",
w0)
145 call fson_get(json_data,
"kinetics.gelPoint",
gelpointconv)
147 call fson_get(json_data,
"kinetics.useDilution",
dilution)
149 json_data,
"initialConditions.concentrations.polyol",
oh0)
151 json_data,
"initialConditions.concentrations.isocyanate",
nco0)
153 json_data,
"kinetics.gellingReaction.frequentialFactor",
aoh)
155 json_data,
"kinetics.gellingReaction.activationEnergy",
eoh)
157 json_data,
"kinetics.blowingReaction.frequentialFactor",
aw)
159 json_data,
"kinetics.blowingReaction.activationEnergy",
ew)
162 json_data,
"initialConditions.concentrations.catalyst",
catalyst)
164 json_data,
"initialConditions.concentrations.polyol1",
polyol1_ini)
166 json_data,
"initialConditions.concentrations.polyol2",
polyol2_ini)
168 json_data,
"initialConditions.concentrations.amine",
amine_ini)
170 json_data,
"initialConditions.concentrations.isocyanate1", &
173 json_data,
"initialConditions.concentrations.isocyanate2", &
176 json_data,
"initialConditions.concentrations.isocyanate3", &
182 "initialConditions.concentrations.blowingAgents.PBL",
cbl(1))
185 "initialConditions.concentrations.blowingAgents.CO2",
cbl(2))
188 json_data,
"kinetics.gellingReaction.reactionEnthalpy",
dhoh)
190 json_data,
"kinetics.blowingReaction.reactionEnthalpy",
dhw)
193 json_data,
"physicalProperties.polymer.polymerDensityModel", strval)
194 if (strval==
"constant")
then 196 call fson_get(json_data,
"physicalProperties.polymer.density",
rhop)
197 elseif (strval==
"nanotools")
then 199 elseif (strval==
"pcsaft")
then 202 stop
'unknown polymer density model' 204 call fson_get(json_data,
"physicalProperties.surfaceTensionModel", strval)
205 if (strval==
"constant")
then 207 call fson_get(json_data,
"physicalProperties.surfaceTension",
sigma)
208 elseif (strval==
"pcsaft")
then 213 stop
'unknown interfacial tension model' 217 "physicalProperties.blowingAgents.PBL.diffusivityModel", strval)
218 if (strval==
"constant")
then 222 "physicalProperties.blowingAgents.PBL.diffusivity",
d(1))
223 elseif (strval==
"nanotools")
then 226 stop
'unknown diffusivity model' 230 "physicalProperties.blowingAgents.CO2.diffusivityModel", strval)
231 if (strval==
"constant")
then 235 "physicalProperties.blowingAgents.CO2.diffusivity",
d(2))
236 elseif (strval==
"nanotools")
then 239 stop
'unknown diffusivity model' 243 "physicalProperties.blowingAgents.PBL.solubilityModel", strval)
244 if (strval==
"constant")
then 248 "physicalProperties.blowingAgents.PBL.solubility",
kh(1))
249 elseif (strval==
"pcsaft")
then 251 elseif (strval==
"Gupta")
then 253 elseif (strval==
"Winkler")
then 255 elseif (strval==
"Baser")
then 257 elseif (strval==
"hardcodedWinkler")
then 260 stop
'unknown solubility model' 264 "physicalProperties.blowingAgents.CO2.solubilityModel", strval)
265 if (strval==
"constant")
then 267 elseif (strval==
"pcsaft")
then 269 elseif (strval==
"hardcodedconstant")
then 273 "physicalProperties.blowingAgents.CO2.solubility",
kh(2))
275 stop
'unknown solubility model' 278 json_data,
"physicalProperties.polymer.viscosityModel", strval)
279 if (strval==
"constant")
then 281 call fson_get(json_data,
"physicalProperties.polymer.viscosity",
eta)
282 elseif (strval==
"hardcodedCastroMacosko")
then 284 elseif (strval==
"CastroMacosko")
then 287 stop
'unknown viscosity model' 289 call fson_destroy(json_data)
290 write(*,*)
'done: inputs loaded' 292 end subroutine read_inputs
301 subroutine save_integration_header
303 write(fi1,
'(1000A24)')
'#time',
'radius',
'pressure1',
'pressure2',&
304 'conversion_of_polyol',&
305 'conversion_of_water',
'eq_concentration',
'first_concentration', &
306 'viscosity',
'moles_in_polymer',
'moles_in_bubble',
'total_moles', &
307 'shell_thickness',
'temperature',
'foam_density',
'weight_fraction1', &
308 'weight_fraction2',
'porosity' 310 write(fi2,
'(1000A23)')
'#GrowthRate1',
'GrowthRate2',
'temperature', &
311 'bubbleRadius',
'c1',
'c2',
'p1',
'p2' 314 write(fi3,
'(1000A23)')
"time",
"Catalyst_1",
"CE_A0",
"CE_A1",
"CE_B",&
315 "CE_B2",
"CE_I0",
"CE_I1",
"CE_I2",
"CE_PBA",
"CE_Breac",
"CE_Areac0",&
316 "CE_Areac1",
"CE_Ireac0",
"CE_Ireac1",
"CE_Ireac2",
"Bulk",
"R_1",&
317 "R_1_mass",
"R_1_temp",
"R_1_vol" 319 open (unit=newunit(fi4), file =
outputs_c)
321 write(
fi5,
'(1000A24)')
'#time',
'radius',
'porosity',
'viscosity' 322 end subroutine save_integration_header
330 subroutine save_integration_step(iout)
331 integer,
intent(in) :: iout
351 init_bub_rad(iout,1)=
time 352 init_bub_rad(iout,2)=
radius 353 end subroutine save_integration_step
361 subroutine save_integration_close(iout)
362 integer,
intent(in) :: iout
363 real(dp),
dimension(:,:),
allocatable :: matr
372 write(fi1,
'(1000A24)')
'#foam_density',
'bubble_diameter',
'pressure1',&
378 if (iout /=
its)
then 379 allocate(matr(0:
its,2))
382 allocate(etat(0:iout,2))
386 allocate(port(0:iout,2))
389 deallocate(init_bub_rad)
390 allocate(init_bub_rad(0:iout,2))
391 init_bub_rad=matr(0:iout,:)
393 end subroutine save_integration_close
401 subroutine load_old_results
402 integer :: i,j,ios,fi
403 real(dp),
dimension(:,:),
allocatable :: matrix
407 read(fi,*,iostat=ios)
411 allocate(matrix(j,18))
415 read(fi,*) matrix(i,:)
418 allocate(bub_rad(j-1,2))
419 bub_rad(:,1)=matrix(2:j,1)
420 bub_rad(:,2)=matrix(2:j,2)
422 end subroutine load_old_results
character(len=99) inputs
input file
logical surfactantpresent
surfactant is present - pcsaft caluclation (t/f)
character(len=99) outputs_drain
output file for the wall drainage
real(dp) porosity
foam porosity
logical solcorr
use solubility correction on bubble radius (t/f)
real(dp) polyol1_ini
initial concentration of polyol 1
real(dp), dimension(:), allocatable dhv
evaporation heat of blowing agent (for each gas)
real(dp) st
shell thickness
integer ngas
number of dissolved gases
integer, dimension(:), allocatable sol_model
solubility model 1=constant,2=modena
integer rhop_model
polymer density model. 1=constant,2=modena
real(dp) rhop
polymer density
character(len=99) outputs_kin
output file with variables of detailed kinetic model
real(dp) temp
temperature (K)
real(dp), dimension(:), allocatable y
state variables
real(dp) amine_ini
initial concentration of amine
real(dp) aw
frequential factor of blowing reaction
real(dp) nb0
initial bubble number density
real(dp) radius
bubble radius (m)
real(dp), dimension(:), allocatable kh
Henry constants (for each dissolved gas)
real(dp) aoh
frequential factor of gelling reaction
real(dp) gelpointconv
conversion of polyol at gel point
real(dp), dimension(:), allocatable mb2
moles in bubble
real(dp) rel_tol
relative tolerance
real(dp) w0
initial concentration of water (can be zero)
logical dilution
use dilution effect for kinetics (t/f)
real(dp) isocyanate2_ini
initial concentration of isocyanate 2
real(dp), dimension(:), allocatable pressure
partial 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) rhobl
density of liquid physical blowing agent
real(dp) isocyanate3_ini
initial concentration of isocyanate 3
real(dp), dimension(:), allocatable mbl
blowing agent molar mass (for each dissolved gas)
real(dp) eoh
activation energy of gelling reaction
real(dp) eqconc
equivalent concentration for first gas
character(len=99) fileplacein
location of input files
character(len=99) geometry
geometry 3D=spherical, 2D=cylindrical
integer, dimension(:), allocatable kineq
kinetics state variable equations (indexes)
real(dp) abs_tol
absolute tolerance
real(dp), dimension(:), allocatable cpbll
heat capacity of blowing agent in liquid phase (for each gas)
real(dp) nco0
initial concentration of isocyanate
logical shooting
am I using shooting method (t/f)
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
real(dp), dimension(:), allocatable xgas
initial molar fraction of gases in the bubble
real(dp), dimension(:), allocatable cbl
concentration profile in reaction mixture
integer itens_model
interfacial tension model. 1=constant,2=modena
integer integrator
integrator. 1=dlsode,2=dlsodes
real(dp) rhofoam
foam density
real(dp) temp0
initial temperature
integer co2_pos
carbon dioxide position
real(dp), dimension(:), allocatable d
diffusion coefficients (for each dissolved gas)
character(len=99) outputs_gr
output file for the surrogate model fitting
real(dp), dimension(:), allocatable avconc
average concentration in reaction mixture
character(len=99) outputs_af
final foam properties for foam cond. and foam aging
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), 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) cppol
heat capacity of polymer
real(dp), dimension(2) grrate
growth rate
real(dp) isocyanate1_ini
initial concentration of isocyanate 1
character(len=99) outputs_c
output file with concentration profiles
character(len=99) fileplaceout
location of output files
real(dp) r0
initial radius
real(dp) dhw
blowing reaction enthalpy
namespace with global variables
integer p
number of internal nodes
character(len=99) outputs_1d
output file with scalar variables
real(dp) dhoh
gelling reaction enthalpy
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
real(dp) oh0
initial concentration of polyol (don't set to zero)
real(dp) ew
activation energy of blowing reaction
integer visc_model
viscosity model. 1=constant,2=Castro and Macosko,3=modena
integer xweq
water conversion equation (index)
integer int_meth
stiff or no? See MF for ODEPACK