10 use foamprop
, only: effrad
11 use foamgeom
, only: foam_morpholgy
12 use conduction
, only: effcond
13 use condrad
, only: equcond,cond,alpha,sigma
16 public loadparameters,eqcond,eqcond_por,eqcond_dcell,eqcond_strut
17 character(len=99) :: fileplacein_par=
'./inputs/' 18 character(len=99) :: fileplacein_ref=
'../spectra/' 19 character(len=99) :: fileplaceout=
'./' 20 character(len=99) :: inputs=
'foamConductivity.json',spectra=
'spectra.out' 21 character(len=99) :: nspec=
'spec_n.in' 22 character(len=99) :: kspec=
'spec_k.in' 23 character(len=99) :: gasspec=
'gasspec.in' 24 character(len=99) :: after_foaming,after_foaming0=
'after_foaming.txt' 25 character(len=99) :: bg_res=
'../../foamExpansion/results/bubbleGrowth/' 26 character(len=99) :: qmom0d_res=
'../../foamExpansion/results/CFD0D/' 27 character(len=99) :: qmom3d_res=
'../../foamExpansion/results/CFD3D/' 31 subroutine eqcond(regions)
33 integer,
intent(in) :: regions
35 real(dp),
dimension(:),
allocatable :: regbound,regcond
36 real(dp),
dimension(:,:),
allocatable :: regalpha,regsigma
37 allocate(regbound(regions+1),regcond(regions),regalpha(regions,nbox),&
38 regsigma(regions,nbox),alpha(nz,nbox),sigma(nz,nbox),cond(nz))
40 regbound(i)=(i-1)*dfoam/regions
43 if (por < 0.8_dp)
then 44 write(*,*)
'Radiative prop. not calculated for porosity < 0.8' 45 write(mfi,*)
'Radiative prop. not calculated for porosity < 0.8' 48 open(newunit(fi),file=
'foamConductivity.out')
55 write(*,*)
'TESTING: radiative properties not calculated.' 56 write(*,*)
'Disable test mode if you want more reasonable results.' 59 open(newunit(fi),file=
'foamConductivity.out')
67 regalpha(i,:)=abscoeffbox
68 regsigma(i,:)=scattcoeffbox
69 deallocate(abscoeffbox,scattcoeffbox)
73 if ((i-0.5_dp)*dfoam/nz<regbound(j))
exit 77 alpha(i,:)=regalpha(j,:)
78 sigma(i,:)=regsigma(j,:)
81 deallocate(regbound,regcond,regalpha,regsigma,alpha,sigma,cond)
89 integer :: fi,npoints,i
90 real(dp) :: pormin,pormax,dpor
94 dpor=(pormax-pormin)/(npoints-1)
95 open(newunit(fi),file=
'eqcond_por.csv')
96 write(fi,*)
'porosity,foam_density,eq_cond,Ross_eq_cond,& 101 write(fi,
'(1x,es23.15,7(",",es23.15))') &
102 por,rhof,eqc,eqc_ross,kgas,ksol,krad
107 end subroutine eqcond_por
113 subroutine eqcond_dcell
114 integer :: fi,npoints,i
115 real(dp) :: dcellmin,dcellmax,ddcell
119 ddcell=log10(dcellmax/dcellmin)/(npoints-1)
120 open(newunit(fi),file=
'eqcond_dcell.out')
121 write(fi,
'(1000A23)')
'#porosity',
'eq. conductivity' 123 dcell=dcellmin*10**((i-1)*ddcell)
125 write(fi,
'(1000es23.15)') dcell,eqc
128 end subroutine eqcond_dcell
134 subroutine eqcond_strut
135 integer :: fi,npoints,i
136 real(dp) :: strutmin,strutmax,dstrut
140 dstrut=(strutmax-strutmin)/(npoints-1)
141 open(newunit(fi),file=
'eqcond_strut.out')
142 write(fi,
'(1000A23)')
'#strut content',
'eq. conductivity',
'Ross. eq. cond.' 144 fs=strutmin+(i-1)*dstrut
146 write(fi,
'(1000es23.15)') fs,eqc,eqc_ross
149 end subroutine eqcond_strut
155 subroutine loadparameters
156 use physicalproperties
158 use fson_value_m
, only: fson_value_get
159 type(fson_value),
pointer :: json_data
160 integer :: fi,ios,i,j
161 logical :: file_exists
162 real(dp) :: xO2,xN2,xCO2,xCyP,matr(7)
163 character(len=80) :: strval
164 inputs=trim(adjustl(fileplacein_par))//trim(adjustl(inputs))
165 inquire(file=inputs,exist=file_exists)
166 if (.not. file_exists)
then 168 inquire(file=inputs,exist=file_exists)
169 if (.not. file_exists) stop
'input file not found' 171 spectra=trim(adjustl(fileplaceout))//trim(adjustl(spectra))
172 json_data => fson_parse(inputs)
173 call fson_get(json_data,
"upperBoundary.temperature", temp1)
174 call fson_get(json_data,
"lowerBoundary.temperature", temp2)
175 call fson_get(json_data,
"upperBoundary.emittance", emi1)
176 call fson_get(json_data,
"lowerBoundary.emittance", emi2)
177 call fson_get(json_data,
"gasDensity", rhog)
178 call fson_get(json_data,
"solidDensity", rhos)
179 call fson_get(json_data,
"sourceOfProperty.porosity", strval)
180 if (strval==
"BubbleGrowth")
then 181 after_foaming=trim(adjustl(bg_res))//trim(adjustl(after_foaming0))
182 open(unit=newunit(fi),file=after_foaming)
188 elseif (strval==
"Qmom0D")
then 189 after_foaming=trim(adjustl(qmom0d_res))//trim(adjustl(after_foaming0))
190 open(unit=newunit(fi),file=after_foaming)
196 elseif (strval==
"Qmom3D")
then 197 after_foaming=trim(adjustl(qmom3d_res))//trim(adjustl(after_foaming0))
198 open(unit=newunit(fi),file=after_foaming)
204 elseif (strval==
"DirectInput")
then 205 call fson_get(json_data,
"porosity", por)
207 write(*,*)
'unknown source for porosity' 211 call fson_get(json_data,
"sourceOfProperty.cellSize", strval)
212 if (strval==
"BubbleGrowth")
then 213 after_foaming=trim(adjustl(bg_res))//trim(adjustl(after_foaming0))
214 open(unit=newunit(fi),file=after_foaming)
219 elseif (strval==
"Qmom0D")
then 220 after_foaming=trim(adjustl(qmom0d_res))//trim(adjustl(after_foaming0))
221 open(unit=newunit(fi),file=after_foaming)
226 elseif (strval==
"Qmom3D")
then 227 after_foaming=trim(adjustl(qmom3d_res))//trim(adjustl(after_foaming0))
228 open(unit=newunit(fi),file=after_foaming)
233 elseif (strval==
"DirectInput")
then 234 call fson_get(json_data,
"cellSize", dcell)
236 write(*,*)
'unknown source for cell size' 239 call fson_get(json_data,
"sourceOfProperty.gasComposition", strval)
240 if (strval==
"BubbleGrowth")
then 241 after_foaming=trim(adjustl(bg_res))//trim(adjustl(after_foaming0))
242 open(unit=newunit(fi),file=after_foaming)
249 xcyp=xcyp/(xcyp+xco2)
252 elseif (strval==
"Qmom0D")
then 253 after_foaming=trim(adjustl(qmom0d_res))//trim(adjustl(after_foaming0))
254 open(unit=newunit(fi),file=after_foaming)
261 xcyp=xcyp/(xcyp+xco2)
264 elseif (strval==
"Qmom3D")
then 265 after_foaming=trim(adjustl(qmom3d_res))//trim(adjustl(after_foaming0))
266 open(unit=newunit(fi),file=after_foaming)
273 xcyp=xcyp/(xcyp+xco2)
276 elseif (strval==
"DirectInput")
then 277 call fson_get(json_data,
"gasComposition.O2", xo2)
278 call fson_get(json_data,
"gasComposition.N2", xn2)
279 call fson_get(json_data,
"gasComposition.CO2", xco2)
280 call fson_get(json_data,
"gasComposition.Cyclopentane", xcyp)
282 write(*,*)
'unknown source for gas composition' 285 call fson_get(json_data,
"sourceOfProperty.strutContent", strval)
286 if (strval==
"StrutContent")
then 287 call strutcontent(fs,rhof)
288 elseif (strval==
"DirectInput")
then 289 call fson_get(json_data,
"strutContent", fs)
291 write(*,*)
'unknown source for strut content' 294 call fson_get(json_data,
"sourceOfProperty.wallThickness", strval)
295 if (strval==
"DirectInput")
then 296 call fson_get(json_data,
"wallThickness", dwall)
298 write(*,*)
'unknown source for wall thickness' 301 call fson_get(json_data,
"morphologyInput", strval)
302 if (strval==
"wallThickness")
then 304 elseif (strval==
"strutContent")
then 306 elseif (strval==
"strutSize")
then 308 elseif (strval==
"strutContent2")
then 311 write(*,*)
'unknown choice of morphologyInput' 314 call fson_get(json_data,
"strutSize", dstrut)
315 call fson_get(json_data,
"foamThickness", dfoam)
316 call fson_get(json_data,
"spatialDiscretization", nz)
317 call fson_get(json_data,
"useWallThicknessDistribution", wdist)
319 call fson_get(json_data,
"wallThicknessStandardDeviation", wsdev)
321 call fson_get(json_data,
"numberOfGrayBoxes", nbox)
322 call fson_get(json_data,
"numericalEffectiveConductivity", numcond)
324 call fson_get(json_data,
"structureName", structurename)
326 call fson_get(json_data,
"testMode", testmode)
327 if (temp1<temp2)
then 332 tmean=(temp1+temp2)/2
333 call gasconductivity(cond1,tmean,xo2,xn2,xco2,xcyp)
334 call polymerconductivity(cond2,tmean)
337 write(*,*)
'System information:' 338 write(*,
'(2x,A,1x,es9.3,1x,A)')
'higher temperature:',temp1,
'K' 339 write(*,
'(2x,A,1x,es9.3,1x,A)')
'lower temperature: ',temp2,
'K' 340 write(*,*)
'Phase properties:' 341 write(*,
'(2x,A,1x,es9.3,1x,A)')
'gas conductivity: ',cond1*1e3_dp,
'mW/m/K' 342 write(*,
'(2x,A,1x,es9.3,1x,A)')
'solid conductivity:',cond2*1e3_dp,
'mW/m/K' 343 write(mfi,*)
'System information:' 344 write(mfi,
'(2x,A,1x,es9.3,1x,A)')
'higher temperature:',temp1,
'K' 345 write(mfi,
'(2x,A,1x,es9.3,1x,A)')
'lower temperature: ',temp2,
'K' 346 write(mfi,*)
'Phase properties:' 347 write(mfi,
'(2x,A,1x,es9.3,1x,A)') &
348 'gas conductivity: ',cond1*1e3_dp,
'mW/m/K' 349 write(mfi,
'(2x,A,1x,es9.3,1x,A)') &
350 'solid conductivity:',cond2*1e3_dp,
'mW/m/K' 353 open(newunit(fi),file=trim(adjustl(fileplacein_ref))//trim(adjustl(nspec)))
355 read(fi,*,iostat=ios)
360 allocate(lambdan(j),nwl(j))
362 read(fi,*) lambdan(i),nwl(i)
364 lambdan=lambdan*1e-6_dp
368 open(newunit(fi),file=trim(adjustl(fileplacein_ref))//trim(adjustl(kspec)))
370 read(fi,*,iostat=ios)
375 allocate(lambdak(j),kwl(j))
377 read(fi,*) lambdak(i),kwl(i)
379 lambdak=lambdak*1e-6_dp
384 file=trim(adjustl(fileplacein_ref))//trim(adjustl(gasspec)))
386 read(fi,*,iostat=ios)
391 allocate(lambdagas(j),acgas(j))
393 read(fi,*) lambdagas(i),acgas(i)
395 lambdagas=lambdagas*1e-6_dp
397 end subroutine loadparameters