MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
phys_prop.f90
Go to the documentation of this file.
1 
7 module phys_prop
8  use constants
9  use globals
10  use foaming_globals_m
11  use fmodena
12  use modenastuff
13  implicit none
14  private
15  ! interpolation variables
16  logical :: rb_initialized
17  integer :: rb_kx=4,rb_iknot=0,rb_inbvx
18  real(dp), dimension(:), allocatable :: rb_tx,rb_coef
19  public set_initial_physical_properties,physical_properties,rb,rderiv,&
20  rb_initialized
21 contains
22 !********************************BEGINNING*************************************
27 subroutine set_initial_physical_properties
28  time=tstart
29  if (.not. firstrun) r0=rb(time)
30  radius=r0
31  temp=temp0
32  conv=0.0_dp
33  ! initial bubble contains only air
34  xgas=0
35  xgas(1)=1
36  if (sum(xgas) /= 1) then
37  write(*,*) 'Sum of initial molar fractions of gases in the bubble is &
38  not equal to one. Normalizing...'
39  xgas=xgas/sum(xgas)
40  write(*,*) 'New initial molar fractions of gases in the bubble'
41  write(*,*) xgas
42  endif
43  call createmodenamodels
44  select case(rhop_model) !density is kept constant, calculate it only once
45  case(1)
46  case(2)
47  call modena_inputs_set(rhopinputs, rhoptpos, temp)
48  call modena_inputs_set(rhopinputs, rhopxohpos, 0.1_dp)
49  ret = modena_model_call(rhopmodena, rhopinputs, rhopoutputs)
50  if(ret /= 0) then
51  call exit(ret)
52  endif
53  rhop = modena_outputs_get(rhopoutputs, 0_c_size_t)
54  call modena_inputs_set(rhopinputs, rhoptpos, temp+100)
55  call modena_inputs_set(rhopinputs, rhopxohpos, 0.9_dp)
56  ret = modena_model_call(rhopmodena, rhopinputs, rhopoutputs)
57  if(ret /= 0) then
58  call exit(ret)
59  endif
60  !average density during foaming
61  rhop=(rhop + modena_outputs_get(rhopoutputs, 0_c_size_t))/2
62  case(3)
63  call modena_inputs_set(rhopinputs, rhoptpos, temp)
64  ret = modena_model_call(rhopmodena, rhopinputs, rhopoutputs)
65  if(ret /= 0) then
66  call exit(ret)
67  endif
68  rhop = modena_outputs_get(rhopoutputs, 0_c_size_t)
69  call modena_inputs_set(rhopinputs, rhoptpos, temp+100)
70  ret = modena_model_call(rhopmodena, rhopinputs, rhopoutputs)
71  if(ret /= 0) then
72  call exit(ret)
73  endif
74  !average density during foaming
75  rhop=(rhop + modena_outputs_get(rhopoutputs, 0_c_size_t))/2
76  end select
77  call physical_properties(temp,conv,radius)
78  d0=d
79  surface_tension=sigma
80  if (geometry=="3D") then
81  pair0=(pamb+2*sigma/radius)*xgas(1)
82  sn=(1._dp/(nb0*4._dp/3*pi*r0**3)+1)**(1._dp/3)
83  s0=sn*radius
84  vsh=4*pi/3*(s0**3-r0**3)
85  elseif (geometry=="2D") then
87  sn=(1._dp/(nb0*pi*r0**2)+1)**(1._dp/2)
88  s0=sn*radius
89  vsh=pi*(s0**2-r0**2)
90  endif
91  gelpoint=.false.
92  timestep=(tend-tstart)/its
93  if (firstrun) then
94  if (allocated(etat)) deallocate(etat)
95  if (allocated(port)) deallocate(port)
96  if (allocated(init_bub_rad)) deallocate(init_bub_rad)
97  allocate(etat(0:its,2),port(0:its,2),init_bub_rad(0:its,2))
98  endif
99 end subroutine set_initial_physical_properties
100 !***********************************END****************************************
101 
102 
103 !********************************BEGINNING*************************************
107 subroutine physical_properties(temp,conv,radius)
108  real(dp), intent(in) :: temp
109  real(dp), intent(in) :: conv
110  real(dp), intent(in) :: radius
111  integer :: i
112  real(dp) :: Aeta,Eeta,Cg,AA,B !viscosity model constants
113  if (temp>500) then
114  print*, 'temperature > 500', temp
115  return
116  endif
117  if (.not. gelpoint) then
118  select case(visc_model)
119  case(1)
120  case(2)
121  aeta=4.1e-8_dp
122  eeta=38.3e3_dp
123  aa=4.0_dp
124  b=-2.0_dp
125  eta=aeta*exp(eeta/(rg*temp))*&
126  (gelpointconv/(gelpointconv-conv))**(aa+b*conv)
127  if (eta>1e10) eta=1.0e10_dp
128  case(3)
129  !set input vector
130  call modena_inputs_set(viscinputs, visctpos, temp);
131  call modena_inputs_set(viscinputs, viscxpos, conv);
132  !call model
133  ret = modena_model_call(viscmodena, viscinputs, viscoutputs)
134  if(ret /= 0) then
135  call exit(ret)
136  endif
137  !fetch results
138  eta = modena_outputs_get(viscoutputs, 0_c_size_t);
139  end select
140  if (conv>gelpointconv*0.9_dp) then
141  gelpoint=.true.
142  endif
143  endif
144  select case(itens_model)
145  case(1)
146  case(2)
147  call modena_inputs_set(itensinputs, itenstpos, temp)
148  ret = modena_model_call(itensmodena, itensinputs, itensoutputs)
149  if(ret /= 0) then
150  call exit(ret)
151  endif
152  sigma = modena_outputs_get(itensoutputs, 0_c_size_t)*1e-3_dp
153  end select
154  do i=1,ngas
155  select case(diff_model(i))
156  case(2)
157  call modena_inputs_set(diffinputs(i), difftpos(i), temp)
158  ret = modena_model_call(diffmodena(i),diffinputs(i),diffoutputs(i))
159  if(ret /= 0) then
160  call exit(ret)
161  endif
162  d(i) = modena_outputs_get(diffoutputs(i), 0_c_size_t)
163  end select
164  select case(sol_model(i))
165  case(1) !constant Baser 10.1002/pen.760340805
166  call modena_inputs_set(solinputs(i), soltpos(i), temp)
167  ret = modena_model_call(solmodena(i), solinputs(i), soloutputs(i))
168  if(ret /= 0) then
169  call exit(ret)
170  endif
171  kh(i) = modena_outputs_get(soloutputs(i), 0_c_size_t)
172  case(2) !pcsaft
173  ! TODO: implement properly
174  call modena_inputs_set(solinputs(i), soltpos(i), temp)
175  call modena_inputs_set(solinputs(i), solxgaspos(i), 1.0e-4_dp)
176  call modena_inputs_set(solinputs(i), solxmdipos(i), 0.5_dp)
177  call modena_inputs_set(solinputs(i), solxpolyolpos(i), 0.5_dp)
178  ret = modena_model_call(solmodena(i), solinputs(i), soloutputs(i))
179  if(ret /= 0) then
180  call exit(ret)
181  endif
182  kh(i) = modena_outputs_get(soloutputs(i), 0_c_size_t)
183  ! KH(i)=rhop/Mbl(i)/KH(i)
184  case(3) !n-pentane, Gupta, 10.1002/pen.11405
185  call modena_inputs_set(solinputs(i), soltpos(i), temp)
186  ret = modena_model_call(solmodena(i), solinputs(i), soloutputs(i))
187  if(ret /= 0) then
188  call exit(ret)
189  endif
190  kh(i) = modena_outputs_get(soloutputs(i), 0_c_size_t)
191  case(4) !pentane, Winkler Ph.D.
192  call modena_inputs_set(solinputs(i), soltpos(i), temp)
193  ret = modena_model_call(solmodena(i), solinputs(i), soloutputs(i))
194  if(ret /= 0) then
195  call exit(ret)
196  endif
197  kh(i) = modena_outputs_get(soloutputs(i), 0_c_size_t)
198  case(6) !R11, Baser, 10.1002/pen.760340804
199  call modena_inputs_set(solinputs(i), soltpos(i), temp)
200  ret = modena_model_call(solmodena(i), solinputs(i), soloutputs(i))
201  if(ret /= 0) then
202  call exit(ret)
203  endif
204  kh(i) = modena_outputs_get(soloutputs(i), 0_c_size_t)
205  case(7) !pentane, Winkler Ph.D.
206  kh(i)=rhop/mbl(i)/pamb*(0.0064_dp+0.0551_dp*exp(-(temp-298)**2/&
207  (2*17.8_dp**2)))
208  case(8) !constant Baser 10.1002/pen.760340805
209  end select
210  enddo
211  if (solcorr) then
212  if (geometry=="3D") then
213  kh=kh*exp(2*sigma*mbl/(rhop*rg*temp*radius))
214  elseif (geometry=="2D") then
215  kh=kh*exp(sigma*mbl/(rhop*rg*temp*radius))
216  endif
217  endif
218  cp=cppol+sum(cbl*mbl*cpbll)/rhop
219 end subroutine physical_properties
220 !***********************************END****************************************
221 
222 
223 !********************************BEGINNING*************************************
227 real(dp) function rderiv(t)
228  use bspline_module
229  real(dp), intent(in) :: t
230  real(dp) :: dt
231  integer :: nx,idx,iflag
232  ! dt=timestep/100
233  ! Rderiv=(Rb(t+dt)-Rb(t))/dt
234  nx=size(bub_rad(:,1))
235  if (.not. rb_initialized) then
236  call rb_spline_ini
237  endif
238  idx=1
239  call db1val(t,idx,rb_tx,nx,rb_kx,rb_coef,rderiv,iflag,rb_inbvx)
240  if (iflag /= 0) then
241  print*, 'evaluation of bubble radius derivative from spline failed',&
242  iflag
243  stop
244  endif
245 endfunction rderiv
246 !***********************************END****************************************
247 
248 
249 !********************************BEGINNING*************************************
253 real(dp) function rb(t)
254  use bspline_module
255  use interpolation
256  real(dp), intent(in) :: t
257  integer :: nx,idx,iflag
258  integer :: ni=1 !number of points, where we want to interpolate
259  real(dp) :: xi(1) !x-values of points, where we want to interpolate
260  real(dp) :: yi(1) !interpolated y-values
261  nx=size(bub_rad(:,1))
262  ! xi(1)=t
263  ! call pwl_interp_1d ( nx, bub_rad(:,1), bub_rad(:,bub_inx+1), ni, xi, yi )
264  ! Rb=yi(1)
265  if (.not. rb_initialized) then
266  call rb_spline_ini
267  endif
268  idx=0
269  call db1val(t,idx,rb_tx,nx,rb_kx,rb_coef,rb,iflag,rb_inbvx)
270  if (iflag /= 0) then
271  print*, 'evaluation of bubble radius from spline failed',iflag
272  stop
273  endif
274 endfunction rb
275 !***********************************END****************************************
276 
277 
278 !********************************BEGINNING*************************************
282 subroutine rb_spline_ini
283  use bspline_module
284  integer :: nx,iflag
285  nx=size(bub_rad(:,1))
286  if (allocated(rb_tx)) deallocate(rb_tx)
287  if (allocated(rb_coef)) deallocate(rb_coef)
288  allocate(rb_tx(nx+rb_kx),rb_coef(nx))
289  rb_tx=0
290  call db1ink(bub_rad(:,1),nx,bub_rad(:,bub_inx+1),&
291  rb_kx,rb_iknot,rb_tx,rb_coef,iflag)
292  rb_inbvx=1
293  rb_initialized=.true.
294  if (iflag /= 0) then
295  print*, 'initialization of spline failed'
296  stop
297  endif
298 end subroutine rb_spline_ini
299 !***********************************END****************************************
300 end module phys_prop
logical gelpoint
gel point reached (t/f)
Definition: globals.f90:22
logical solcorr
use solubility correction on bubble radius (t/f)
Definition: globals.f90:22
integer ngas
number of dissolved gases
Definition: globals.f90:29
integer, dimension(:), allocatable sol_model
solubility model 1=constant,2=modena
Definition: globals.f90:102
integer rhop_model
polymer density model. 1=constant,2=modena
Definition: globals.f90:29
real(dp) rhop
polymer density
Definition: globals.f90:49
real(dp) temp
temperature (K)
Definition: globals.f90:49
real(dp) nb0
initial bubble number density
Definition: globals.f90:49
real(dp) pair0
initial partial pressure of air
Definition: globals.f90:49
real(dp) radius
bubble radius (m)
Definition: globals.f90:49
real(dp), dimension(:), allocatable kh
Henry constants (for each dissolved gas)
Definition: globals.f90:106
real(dp) gelpointconv
conversion of polyol at gel point
Definition: globals.f90:49
real(dp) sn
how many times is initial shell larger than initial bubble radius
Definition: globals.f90:49
real(dp) s0
initial shell thickness
Definition: globals.f90:49
real(dp) sigma
interfacial tension
Definition: globals.f90:49
integer, dimension(:), allocatable diff_model
diffusivity model 1=constant,2=modena
Definition: globals.f90:102
real(dp), dimension(:), allocatable mbl
blowing agent molar mass (for each dissolved gas)
Definition: globals.f90:106
real(dp) conv
conversion of polyol
Definition: globals.f90:49
real(dp) time
time (s)
Definition: globals.f90:49
character(len=99) geometry
geometry 3D=spherical, 2D=cylindrical
Definition: globals.f90:11
real(dp), dimension(:), allocatable cpbll
heat capacity of blowing agent in liquid phase (for each gas)
Definition: globals.f90:106
real(dp), dimension(:), allocatable d0
initial diffusion coefficients used in non-dimensional routines
Definition: globals.f90:106
real(dp), dimension(:), allocatable xgas
initial molar fraction of gases in the bubble
Definition: globals.f90:106
real(dp), dimension(:), allocatable cbl
concentration profile in reaction mixture
Definition: globals.f90:106
integer itens_model
interfacial tension model. 1=constant,2=modena
Definition: globals.f90:29
real(dp) temp0
initial temperature
Definition: globals.f90:49
real(dp), dimension(:), allocatable d
diffusion coefficients (for each dissolved gas)
Definition: globals.f90:106
real(dp) pamb
ambient pressure (in the liquid)
Definition: globals.f90:49
real(dp) vsh
shell volume
Definition: globals.f90:49
real(dp) timestep
timestep
Definition: globals.f90:49
real(dp) eta
viscosity
Definition: globals.f90:49
integer its
number of outer integration outer time steps
Definition: globals.f90:29
real(dp) cp
heat capacity of the reaction mixture
Definition: globals.f90:49
real(dp) cppol
heat capacity of polymer
Definition: globals.f90:49
real(dp) r0
initial radius
Definition: globals.f90:49
namespace with global variables
Definition: globals.f90:8
integer visc_model
viscosity model. 1=constant,2=Castro and Macosko,3=modena
Definition: globals.f90:29