eos_oil.F90 coverage: 70.45 %func 56.06 %block
1) module EOS_Oil_module
2)
3) use PFLOTRAN_Constants_module
4) use EOSDatabase_module
5)
6) implicit none
7)
8) private
9)
10) #include "petsc/finclude/petscsys.h"
11)
12) ! module variables
13) PetscReal :: fmw_oil
14) PetscReal :: constant_density !kg/m3
15) PetscReal :: constant_enthalpy
16) PetscReal :: constant_viscosity
17) PetscReal :: constant_sp_heat
18) ! quadratic viscosity
19) PetscReal :: quad_vis0
20) PetscReal :: quad_vis_ref_pres(2)
21) PetscReal :: quad_vis_ref_temp(2)
22) PetscReal :: quad_vis_pres_coef(2)
23) PetscReal :: quad_vis_temp_coef(2)
24) ! parameters for linear density
25) PetscReal :: compress_coeff
26) PetscReal :: th_expansion_coeff
27) PetscReal :: den_linear_den0
28) PetscReal :: den_linear_ref_pres
29) PetscReal :: den_linear_ref_temp
30)
31) ! EOS databases
32) class(eos_database_type), pointer :: eos_dbase
33) class(eos_database_type), pointer :: eos_den_dbase
34) class(eos_database_type), pointer :: eos_ent_dbase
35) class(eos_database_type), pointer :: eos_vis_dbase
36) ! when adding a new eos_database, remember to add it to EOSOilDBaseDestroy()
37)
38) ! In order to support generic EOS subroutines, we need the following:
39) ! 1. An interface declaration that defines the argument list (best to have
40) ! "Dummy" appended.
41) ! 2. A procedure pointer that is initially set to null. This pointer is
42) ! pointed to the appropriate subroutine later on (e.g. EOSOilInit())
43) ! 3. An interface for derivative/non-derivative versions
44)
45) ! procedure pointers
46)
47) procedure(EOSOilViscosityDummy), pointer :: EOSOilViscosityPtr => null()
48) procedure(EOSOilDensityDummy), pointer :: EOSOilDensityPtr => null()
49) procedure(EOSOilEnthalpyDummy), pointer :: EOSOilEnthalpyPtr => null()
50) procedure(EOSOilDensityEnergyDummy), pointer :: &
51) EOSOilDensityEnergyPtr => null()
52)
53) ! these should be define as astract interfaces, because there are no
54) ! precedures named as xxxDummy that have such interfaces
55) interface
56) subroutine EOSOilViscosityDummy(T,P,Rho,deriv,Vis,dVis_dT,dVis_dP,ierr)
57) implicit none
58) PetscReal, intent(in) :: T ! temperature [C]
59) PetscReal, intent(in) :: P ! oil pressure [Pa]
60) PetscReal, intent(in) :: Rho ! oil density [kmol/m3]
61) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
62) PetscReal, intent(out) :: Vis ! oil viscosity
63) PetscReal, intent(out) :: dVis_dT ! derivative oil viscosity wrt temperature
64) PetscReal, intent(out) :: dVis_dP ! derivative oil viscosity wrt Pressure
65) PetscErrorCode, intent(out) :: ierr
66) end subroutine EOSOilViscosityDummy
67) subroutine EOSOilDensityDummy(T, P, deriv, Rho, dRho_dT, dRho_dP, ierr)
68) implicit none
69) PetscReal, intent(in) :: T ! temperature [C]
70) PetscReal, intent(in) :: P ! pressure [Pa]
71) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
72) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
73) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
74) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
75) PetscErrorCode, intent(out) :: ierr
76) end subroutine EOSOilDensityDummy
77) subroutine EOSOilEnthalpyDummy(T,P,deriv,H,dH_dT,dH_dP,ierr)
78) implicit none
79) PetscReal, intent(in) :: T ! temperature [C]
80) PetscReal, intent(in) :: P ! pressure [Pa]
81) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
82) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
83) PetscReal, intent(out) :: dH_dT ! derivative enthalpy wrt temperature
84) PetscReal, intent(out) :: dH_dP ! derivative enthalpy wrt pressure
85) PetscErrorCode, intent(out) :: ierr
86) end subroutine EOSOilEnthalpyDummy
87) subroutine EOSOilDensityEnergyDummy(T,P,deriv,Rho,dRho_dT,dRho_dP, &
88) H,dH_dT,dH_dP,U,dU_dT,dU_dP,ierr)
89) implicit none
90) PetscReal, intent(in) :: T ! temperature [C]
91) PetscReal, intent(in) :: P ! pressure [Pa]
92) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
93) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
94) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
95) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
96) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
97) PetscReal, intent(out) :: dH_dT ! derivative enthalpy wrt temperature
98) PetscReal, intent(out) :: dH_dP ! derivative enthalpy wrt pressure
99) PetscReal, intent(out) :: U ! internal energy [J/kmol]
100) PetscReal, intent(out) :: dU_dT ! deriv. internal energy wrt temperature
101) PetscReal, intent(out) :: dU_dP ! deriv. internal energy wrt pressure
102) PetscErrorCode, intent(out) :: ierr
103) end subroutine EOSOilDensityEnergyDummy
104) end interface
105)
106) ! interfaces for derivative/non-derivative versions that are visible outside
107) ! the module.
108) interface EOSOilViscosity
109) procedure EOSOilViscosityNoDerive
110) ! procedure EOSOilViscosityDerive
111) end interface
112) interface EOSOilDensity
113) procedure EOSOilDensityNoDerive
114) procedure EOSOilDensityDerive
115) end interface
116) interface EOSOilEnthalpy
117) procedure EOSOilEnthalpyNoDerive
118) ! procedure EOSOilEnthalpyDerive
119) end interface
120) interface EOSOilDensityEnergy
121) procedure EOSOilDenEnergyNoDerive
122) ! procedure EOSOilDenEnergyDerive
123) end interface
124)
125)
126) public :: EOSOilInit, &
127) EOSOilVerify, &
128) EOSOilViscosity, &
129) EOSOilDensity, &
130) EOSOilEnthalpy, &
131) EOSOilDensityEnergy, &
132) EOSOilInputRecord
133)
134) public :: EOSOilSetFMWConstant, &
135) EOSOilGetFMW, &
136) EOSOilSetViscosityConstant, &
137) EOSOilSetViscosityQuad, &
138) EOSOilSetVisQuadRefVis, &
139) EOSOilSetVisQuadRefPres, &
140) EOSOilSetVisQuadRefTemp, &
141) EOSOilSetVisQuadPresCoef, &
142) EOSOilSetVisQuadTempCoef, &
143) EOSOilSetVisDBase, &
144) EOSOilSetDensityConstant, &
145) EOSOilSetDensityLinear, &
146) EOSOilSetDenLinearRefDen, &
147) EOSOilSetDenLinearComprCoef, &
148) EOSOilSetDenLinearExpanCoef, &
149) EOSOilSetDenLinearRefPres, &
150) EOSOilSetDenLinearRefTemp, &
151) EOSOilSetDenDBase, &
152) EOSOilSetEnthalpyConstant, &
153) EOSOilSetEnthalpyLinearTemp, &
154) EOSOilSetEntDBase, &
155) EOSOilSetEOSDBase, &
156) EOSOilDBaseDestroy
157)
158) contains
159)
160) ! ************************************************************************** !
161)
162) subroutine EOSOilInit()
163)
164) implicit none
165)
166) constant_density = UNINITIALIZED_DOUBLE
167) constant_viscosity = UNINITIALIZED_DOUBLE
168) constant_enthalpy = UNINITIALIZED_DOUBLE
169)
170) quad_vis0 = UNINITIALIZED_DOUBLE
171) quad_vis_ref_pres(1:2) = UNINITIALIZED_DOUBLE
172) quad_vis_ref_temp(1:2) = UNINITIALIZED_DOUBLE
173) quad_vis_pres_coef(1:2) = UNINITIALIZED_DOUBLE
174) quad_vis_temp_coef(1:2) = UNINITIALIZED_DOUBLE
175)
176) compress_coeff = UNINITIALIZED_DOUBLE
177) th_expansion_coeff = UNINITIALIZED_DOUBLE
178) den_linear_den0 = UNINITIALIZED_DOUBLE
179) den_linear_ref_pres = UNINITIALIZED_DOUBLE
180) den_linear_ref_temp = UNINITIALIZED_DOUBLE
181)
182) fmw_oil = FMWOIL !default oil formula weight C10H22 (142 g/mol)
183)
184) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
185)
186) nullify(EOSOilViscosityPtr)
187) nullify(EOSOilDensityPtr)
188) nullify(EOSOilEnthalpyPtr)
189)
190) nullify(eos_dbase)
191) nullify(eos_den_dbase)
192) nullify(eos_ent_dbase)
193) nullify(eos_vis_dbase)
194)
195) ! could decide for a default model, but it only if there is one that
196) ! does nto require input parameters
197) !EOSOilViscosityPtr => EOSOilViscosityConstant
198) !EOSOilDensityPtr => EOSOilDensityConstant
199) !EOSOilEnthalpyPtr => EOSOilEnthalpyConstant
200)
201) end subroutine EOSOilInit
202)
203) ! ************************************************************************** !
204)
205) subroutine EOSOilVerify(ierr,error_string)
206)
207) implicit none
208)
209) PetscErrorCode, intent(out) :: ierr
210) character(len=MAXSTRINGLENGTH), intent(out) :: error_string
211)
212) ierr = 0
213)
214) error_string = ''
215) if (.not.associated(EOSOilDensityPtr) ) then
216) error_string = trim(error_string) // ' Oil Density model not defined'
217) ierr = 1
218) return
219) end if
220) if (.not.associated(EOSOilEnthalpyPtr) ) then
221) error_string = trim(error_string) // ' Oil Enthalpy model not defined'
222) ierr = 1
223) return
224) end if
225) if (.not.associated(EOSOilViscosityPtr) ) then
226) error_string = trim(error_string) // ' Oil Viscosity model not defined'
227) ierr = 1
228) return
229) end if
230)
231) if ( associated(EOSOilDensityPtr,EOSOilDensityConstant).and. &
232) Uninitialized(constant_density) &
233) ) then
234) error_string = trim(error_string) // &
235) ' Oil Constant Density selcected without providing a value'
236) ierr = 1
237) return
238) end if
239)
240) if ( associated(EOSOilDensityPtr,EOSOilDensityEOSDBase) ) then
241) if ( .not.eos_dbase%EOSPropPresent(EOS_DENSITY) ) then
242) error_string = trim(error_string) // &
243) ' Oil Density to be interpolated from database = ' // &
244) eos_dbase%file_name // &
245) ' which does not have data for density'
246) ierr = 1
247) return
248) end if
249) end if
250)
251) if ( associated(EOSOilDensityPtr,EOSOilDensityDenDBase) ) then
252) if ( .not.eos_den_dbase%EOSPropPresent(EOS_DENSITY) ) then
253) error_string = trim(error_string) // &
254) ' Oil Density to be interpoalted from database = ' // &
255) eos_dbase%file_name // &
256) ' which does not have data for density'
257) ierr = 1
258) return
259) end if
260) end if
261)
262) if ( associated(EOSOilEnthalpyPtr,EOSOilEnthalpyConstant).and. &
263) Uninitialized(constant_enthalpy) &
264) ) then
265) error_string = trim(error_string) // &
266) ' Oil Constant Enthalpy selcected without providing a value'
267) ierr = 1
268) return
269) end if
270)
271) if ( associated(EOSOilEnthalpyPtr,EOSOilEnthalpyEOSDBase) ) then
272) if ( .not.eos_dbase%EOSPropPresent(EOS_ENTHALPY) ) then
273) error_string = trim(error_string) // &
274) ' Oil Enthalpy to be interpolated from database = ' // &
275) eos_dbase%file_name // &
276) ' which does not have data for Enthalpy'
277) ierr = 1
278) return
279) end if
280) end if
281)
282) if ( associated(EOSOilEnthalpyPtr,EOSOilEnthalpyEntDBase) ) then
283) if ( .not.eos_ent_dbase%EOSPropPresent(EOS_ENTHALPY) ) then
284) error_string = trim(error_string) // &
285) ' Oil Density to be interpolated from database = ' // &
286) eos_dbase%file_name // &
287) ' which does not have data for enthalpy'
288) ierr = 1
289) return
290) end if
291) end if
292)
293) if ( associated(EOSOilViscosityPtr,EOSOilViscosityConstant).and. &
294) Uninitialized(constant_viscosity) &
295) ) then
296) error_string = trim(error_string) // &
297) ' Oil Constant Viscosity selcected without providing a value'
298) ierr = 1
299) return
300) end if
301)
302) if ( associated(EOSOilViscosityPtr,EOSOilViscosityEOSDBase) ) then
303) if ( .not.eos_dbase%EOSPropPresent(EOS_VISCOSITY) ) then
304) error_string = trim(error_string) // &
305) ' Oil Enthalpy to be interpolated from database = ' // &
306) eos_dbase%file_name // &
307) ' which does not have data for Viscosity'
308) ierr = 1
309) return
310) end if
311) end if
312)
313) if ( associated(EOSOilViscosityPtr,EOSOilViscosityVisDBase) ) then
314) if ( .not.eos_vis_dbase%EOSPropPresent(EOS_VISCOSITY) ) then
315) error_string = trim(error_string) // &
316) ' Oil Density to be interpolated from database = ' // &
317) eos_dbase%file_name // &
318) ' which does not have data for visosity'
319) ierr = 1
320) return
321) end if
322) end if
323)
324) end subroutine EOSOilVerify
325)
326) ! ************************************************************************** !
327)
328) subroutine EOSOilSetFMWConstant(fmw_input)
329)
330) implicit none
331)
332) PetscReal :: fmw_input
333)
334) fmw_oil = fmw_input
335)
336) end subroutine EOSOilSetFMWConstant
337)
338) ! ************************************************************************** !
339)
340) function EOSOilGetFMW()
341)
342) implicit none
343)
344) PetscReal :: EOSOilGetFMW
345)
346) EOSOilGetFMW = fmw_oil
347)
348) end function EOSOilGetFMW
349)
350) ! ************************************************************************** !
351)
352) subroutine EOSOilSetViscosityConstant(viscosity)
353)
354) implicit none
355)
356) PetscReal :: viscosity
357)
358) constant_viscosity = viscosity
359) EOSOilViscosityPtr => EOSOilViscosityConstant
360)
361) end subroutine EOSOilSetViscosityConstant
362)
363) ! ************************************************************************** !
364)
365) subroutine EOSOilSetViscosityQuad()
366)
367) implicit none
368)
369) EOSOilViscosityPtr => EOSOilQuadViscosity
370)
371) end subroutine EOSOilSetViscosityQuad
372)
373) ! ************************************************************************** !
374)
375) subroutine EOSOilSetVisQuadRefVis(vis0)
376)
377) implicit none
378)
379) PetscReal :: vis0
380)
381) quad_vis0 = vis0
382)
383) end subroutine EOSOilSetVisQuadRefVis
384)
385) ! ************************************************************************** !
386)
387) subroutine EOSOilSetVisQuadRefPres(p1,p2)
388)
389) implicit none
390)
391) PetscReal :: p1, p2
392)
393) quad_vis_ref_pres(1) = p1
394) quad_vis_ref_pres(2) = p2
395)
396) end subroutine EOSOilSetVisQuadRefPres
397)
398) ! ************************************************************************** !
399)
400) subroutine EOSOilSetVisQuadRefTemp(t1,t2)
401)
402) implicit none
403)
404) PetscReal :: t1, t2
405)
406) quad_vis_ref_temp(1) = t1
407) quad_vis_ref_temp(2) = t2
408)
409) end subroutine EOSOilSetVisQuadRefTemp
410)
411) ! ************************************************************************** !
412)
413) subroutine EOSOilSetVisQuadPresCoef(a1,a2)
414)
415) implicit none
416)
417) PetscReal :: a1, a2
418)
419) quad_vis_pres_coef(1) = a1
420) quad_vis_pres_coef(2) = a2
421)
422) end subroutine EOSOilSetVisQuadPresCoef
423)
424) ! ************************************************************************** !
425)
426) subroutine EOSOilSetVisQuadTempCoef(b1,b2)
427)
428) implicit none
429)
430) PetscReal :: b1, b2
431)
432) quad_vis_temp_coef(1) = b1
433) quad_vis_temp_coef(2) = b2
434)
435) end subroutine EOSOilSetVisQuadTempCoef
436)
437) ! ************************************************************************** !
438)
439) subroutine EOSOilSetVisDBase(filename,option)
440)
441) use Option_module
442)
443) implicit none
444)
445) character(len=MAXWORDLENGTH) :: filename
446) type(option_type) :: option
447)
448) eos_vis_dbase => EOSDatabaseCreate(filename,'oil_den_database')
449) call eos_vis_dbase%Read(option)
450)
451) !set property function pointers
452) EOSOilViscosityPtr => EOSOilViscosityVisDBase
453)
454) end subroutine EOSOilSetVisDBase
455)
456) ! ************************************************************************** !
457)
458) subroutine EOSOilSetDensityConstant(density)
459)
460) implicit none
461)
462) PetscReal :: density
463)
464) constant_density = density
465) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
466) EOSOilDensityPtr => EOSOilDensityConstant
467)
468) end subroutine EOSOilSetDensityConstant
469)
470) ! ************************************************************************** !
471)
472) subroutine EOSOilSetDensityLinear()
473)
474) implicit none
475)
476) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
477) EOSOilDensityPtr => EOSOilDensityLinear
478)
479) end subroutine EOSOilSetDensityLinear
480)
481) ! ************************************************************************** !
482)
483) subroutine EOSOilSetDenLinearRefDen(den0)
484)
485) implicit none
486)
487) PetscReal :: den0
488)
489) den_linear_den0 = den0
490)
491) end subroutine EOSOilSetDenLinearRefDen
492)
493) ! ************************************************************************** !
494)
495) subroutine EOSOilSetDenLinearRefPres(ref_pres)
496)
497) implicit none
498)
499) PetscReal :: ref_pres
500)
501) den_linear_ref_pres = ref_pres
502)
503) end subroutine EOSOilSetDenLinearRefPres
504)
505) ! ************************************************************************** !
506)
507) subroutine EOSOilSetDenLinearRefTemp(ref_temp)
508)
509) implicit none
510)
511) PetscReal :: ref_temp
512)
513) den_linear_ref_temp = ref_temp
514)
515) end subroutine EOSOilSetDenLinearRefTemp
516)
517) ! ************************************************************************** !
518)
519) subroutine EOSOilSetDenLinearComprCoef(compress_c)
520)
521) implicit none
522)
523) PetscReal :: compress_c
524)
525) compress_coeff = compress_c
526)
527) end subroutine EOSOilSetDenLinearComprCoef
528)
529) ! ************************************************************************** !
530)
531) subroutine EOSOilSetDenLinearExpanCoef(expansion_c)
532)
533) implicit none
534)
535) PetscReal :: expansion_c
536)
537) th_expansion_coeff = expansion_c
538)
539) end subroutine EOSOilSetDenLinearExpanCoef
540)
541) ! ************************************************************************** !
542)
543) subroutine EOSOilSetDenDBase(filename,option)
544)
545) use Option_module
546)
547) implicit none
548)
549) character(len=MAXWORDLENGTH) :: filename
550) type(option_type) :: option
551)
552) eos_den_dbase => EOSDatabaseCreate(filename,'oil_den_database')
553) call eos_den_dbase%Read(option)
554)
555) !set property function pointers
556) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
557) EOSOilDensityPtr => EOSOilDensityDenDBase
558)
559) end subroutine EOSOilSetDenDBase
560)
561) ! ************************************************************************** !
562)
563) subroutine EOSOilSetEnthalpyConstant(enthalpy)
564)
565) implicit none
566)
567) PetscReal :: enthalpy
568)
569) constant_enthalpy = enthalpy
570) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
571) EOSOilEnthalpyPtr => EOSOilEnthalpyConstant
572)
573) end subroutine EOSOilSetEnthalpyConstant
574)
575) ! ************************************************************************** !
576)
577) subroutine EOSOilSetEnthalpyLinearTemp(specific_heat)
578)
579) implicit none
580)
581) PetscReal :: specific_heat
582)
583) constant_sp_heat = specific_heat
584) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
585) EOSOilEnthalpyPtr => EOSOilEnthalpyLinearTemp
586)
587) !write(*,*) "I am in EOS oil linear set up"
588)
589) end subroutine EOSOilSetEnthalpyLinearTemp
590)
591) ! ************************************************************************** !
592)
593) subroutine EOSOilSetEntDBase(filename,option)
594)
595) use Option_module
596)
597) implicit none
598)
599) character(len=MAXWORDLENGTH) :: filename
600) type(option_type) :: option
601)
602) eos_ent_dbase => EOSDatabaseCreate(filename,'oil_ent_database')
603) call eos_ent_dbase%Read(option)
604)
605) !set property function pointers
606) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
607) EOSOilEnthalpyPtr => EOSOilEnthalpyEntDBase
608)
609)
610) end subroutine EOSOilSetEntDBase
611)
612) ! ************************************************************************** !
613)
614) subroutine EOSOilSetEOSDBase(filename,option)
615)
616) use Option_module
617)
618) implicit none
619)
620) character(len=MAXWORDLENGTH) :: filename
621) type(option_type) :: option
622)
623) eos_dbase => EOSDatabaseCreate(filename,'oil_database')
624) call eos_dbase%Read(option)
625)
626) !set property function pointers
627) EOSOilDensityEnergyPtr => EOSOilDensityEnergyTOilIms
628) if (.not.associated(EOSOilDensityPtr)) &
629) EOSOilDensityPtr => EOSOilDensityEOSDBase
630) if (.not.associated(EOSOilEnthalpyPtr)) &
631) EOSOilEnthalpyPtr => EOSOilEnthalpyEOSDBase
632) if (.not.associated(EOSOilViscosityPtr)) &
633) EOSOilViscosityPtr => EOSOilViscosityEOSDBase
634)
635) end subroutine EOSOilSetEOSDBase
636)
637) ! ************************************************************************** !
638)
639) subroutine EOSOilViscosityConstant(T,P,Rho,deriv,Vis,dVis_dT,dVis_dP,ierr)
640)
641) implicit none
642)
643) PetscReal, intent(in) :: T ! temperature [C]
644) PetscReal, intent(in) :: P ! oil pressure [Pa]
645) PetscReal, intent(in) :: Rho ! oil density [kmol/m3]
646) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
647) PetscReal, intent(out) :: Vis ! oil viscosity
648) PetscReal, intent(out) :: dVis_dT ! derivative oil viscosity wrt temperature
649) PetscReal, intent(out) :: dVis_dP ! derivative oil viscosity wrt Pressure
650) PetscErrorCode, intent(out) :: ierr
651)
652) Vis = constant_viscosity
653)
654) dVis_dT = 0.0d0
655) dVis_dP = 0.0d0
656)
657) end subroutine EOSOilViscosityConstant
658)
659) ! ************************************************************************** !
660)
661) subroutine EOSOilQuadViscosity(T,P,Rho,deriv,Vis,dVis_dT,dVis_dP,ierr)
662)
663) implicit none
664)
665) PetscReal, intent(in) :: T ! temperature [C]
666) PetscReal, intent(in) :: P ! oil pressure [Pa]
667) PetscReal, intent(in) :: Rho ! oil density [kmol/m3]
668) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
669) PetscReal, intent(out) :: Vis ! oil viscosity
670) PetscReal, intent(out) :: dVis_dT ! derivative oil viscosity wrt temperature
671) PetscReal, intent(out) :: dVis_dP ! derivative oil viscosity wrt Pressure
672) PetscErrorCode, intent(out) :: ierr
673)
674) Vis = quad_vis0 + &
675) quad_vis_pres_coef(1) * ( P - quad_vis_ref_pres(1) ) + &
676) quad_vis_pres_coef(2) * ( P - quad_vis_ref_pres(2) )**2.0d0 + &
677) quad_vis_temp_coef(1) * ( T - quad_vis_ref_temp(1) ) + &
678) quad_vis_temp_coef(2) * ( T - quad_vis_ref_temp(2) )**2.0d0
679)
680) if (deriv) then
681) dVis_dP = quad_vis_pres_coef(1) + &
682) 2.0d0 * quad_vis_pres_coef(2) * ( P - quad_vis_ref_pres(2) )
683) dVis_dT = quad_vis_temp_coef(1) + &
684) 2.0d0 * quad_vis_temp_coef(2) * ( T - quad_vis_ref_temp(2) )
685) end if
686)
687) end subroutine EOSOilQuadViscosity
688)
689) ! ************************************************************************** !
690)
691) subroutine EOSOilViscosityEOSDBase(T,P,Rho,deriv,Vis,dVis_dT,dVis_dP,ierr)
692)
693) implicit none
694)
695) PetscReal, intent(in) :: T ! temperature [C]
696) PetscReal, intent(in) :: P ! oil pressure [Pa]
697) PetscReal, intent(in) :: Rho ! oil density [kmol/m3]
698) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
699) PetscReal, intent(out) :: Vis ! oil viscosity
700) PetscReal, intent(out) :: dVis_dT ! derivative oil viscosity wrt temperature
701) PetscReal, intent(out) :: dVis_dP ! derivative oil viscosity wrt Pressure
702) PetscErrorCode, intent(out) :: ierr
703)
704) !ierr initialised in EOSEOSProp
705) call eos_dbase%EOSProp(T,P,EOS_VISCOSITY,Vis,ierr)
706)
707) dVis_dT = 0.0d0
708) dVis_dP = 0.0d0
709)
710) if (deriv) then
711) ! not yet implemented
712) ierr = 99 !error 99 points out that deriv are asked but not available yet.
713) print*, "EOSOilViscosityEOSDBase - Viscosity derivatives not supported"
714) stop
715) end if
716)
717) end subroutine EOSOilViscosityEOSDBase
718)
719) ! ************************************************************************** !
720)
721) subroutine EOSOilViscosityVisDBase(T,P,Rho,deriv,Vis,dVis_dT,dVis_dP,ierr)
722)
723) implicit none
724)
725) PetscReal, intent(in) :: T ! temperature [C]
726) PetscReal, intent(in) :: P ! oil pressure [Pa]
727) PetscReal, intent(in) :: Rho ! oil density [kmol/m3]
728) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
729) PetscReal, intent(out) :: Vis ! oil viscosity
730) PetscReal, intent(out) :: dVis_dT ! derivative oil viscosity wrt temperature
731) PetscReal, intent(out) :: dVis_dP ! derivative oil viscosity wrt Pressure
732) PetscErrorCode, intent(out) :: ierr
733)
734) !ierr initialised in EOSEOSProp
735) call eos_vis_dbase%EOSProp(T,P,EOS_VISCOSITY,Vis,ierr)
736)
737) dVis_dT = 0.0d0
738) dVis_dP = 0.0d0
739)
740) if (deriv) then
741) ! not yet implemented
742) ierr = 99 !error 99 points out that deriv are asked but not available yet.
743) print*, "EOSOilViscosityVisDBase - Viscosity derivatives not supported"
744) stop
745) end if
746)
747) end subroutine EOSOilViscosityVisDBase
748)
749) ! ************************************************************************** !
750)
751) subroutine EOSOilViscosityNoDerive(T,P,Rho,Vis,ierr)
752)
753) implicit none
754)
755) PetscReal, intent(in) :: T ! temperature [C]
756) PetscReal, intent(in) :: P ! oil pressure [Pa]
757) PetscReal, intent(in) :: Rho ! oil density [kmol/m3]
758) PetscReal, intent(out) :: Vis ! oil viscosity
759) PetscErrorCode, intent(out) :: ierr
760)
761) PetscReal :: dum1, dum2
762)
763) call EOSOilViscosityPtr(T,P,Rho,PETSC_FALSE,Vis,dum1,dum2,ierr)
764)
765) end subroutine EOSOilViscosityNoDerive
766)
767) ! ************************************************************************** !
768)
769) subroutine EOSOilDensityConstant(T, P, deriv, Rho, dRho_dT, dRho_dP, ierr)
770)
771) implicit none
772)
773) PetscReal, intent(in) :: T ! temperature [C]
774) PetscReal, intent(in) :: P ! pressure [Pa]
775) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
776) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
777) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
778) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
779) PetscErrorCode, intent(out) :: ierr
780) ! kg/m3 * kmol/kg = kmol/m3
781) Rho = constant_density / fmw_oil ! kmol/m^3
782)
783) dRho_dT = 0.d0
784) dRho_dP = 0.d0
785)
786) end subroutine EOSOilDensityConstant
787)
788) ! ************************************************************************** !
789)
790) subroutine EOSOilDensityLinear(T, P, deriv, Rho, dRho_dT, dRho_dP, ierr)
791)
792) implicit none
793)
794) PetscReal, intent(in) :: T ! temperature [C]
795) PetscReal, intent(in) :: P ! pressure [Pa]
796) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
797) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
798) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
799) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
800) PetscErrorCode, intent(out) :: ierr
801)
802) Rho = den_linear_den0 + &
803) compress_coeff * (P - den_linear_ref_pres ) - & ! compression
804) th_expansion_coeff * (T - den_linear_ref_temp ) ! expansion
805)
806) ! conversion to molar density
807) ! kg/m3 * kmol/kg = kmol/m3
808) Rho = Rho / fmw_oil ! kmol/m^3
809)
810) if (deriv) then
811) dRho_dT = compress_coeff / fmw_oil
812) dRho_dP = - th_expansion_coeff / fmw_oil
813) end if
814)
815) end subroutine EOSOilDensityLinear
816)
817) ! ************************************************************************** !
818)
819) subroutine EOSOilDensityEOSDBase(T, P, deriv, Rho, dRho_dT, dRho_dP, ierr)
820)
821) implicit none
822)
823) PetscReal, intent(in) :: T ! temperature [C]
824) PetscReal, intent(in) :: P ! pressure [Pa]
825) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
826) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
827) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
828) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
829) PetscErrorCode, intent(out) :: ierr
830)
831) !ierr initialised in EOSEOSProp
832) call eos_dbase%EOSProp(T,P,EOS_DENSITY,Rho,ierr)
833)
834) ! conversion to molar density
835) ! kg/m3 * kmol/kg = kmol/m3
836) Rho = Rho / fmw_oil ! kmol/m^3
837)
838) if (deriv) then
839) ! not yet implemented
840) ierr = 99 !error 99 points out that deriv are asked but not available yet.
841) print*, "EOSOilDensityEOSDBase - Den derivatives not supported"
842) stop
843) end if
844)
845) end subroutine EOSOilDensityEOSDBase
846)
847) ! ************************************************************************** !
848)
849) subroutine EOSOilDensityDenDBase(T, P, deriv, Rho, dRho_dT, dRho_dP, ierr)
850)
851) implicit none
852)
853) PetscReal, intent(in) :: T ! temperature [C]
854) PetscReal, intent(in) :: P ! pressure [Pa]
855) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
856) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
857) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
858) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
859) PetscErrorCode, intent(out) :: ierr
860)
861) !ierr initialised in EOSEOSProp
862) call eos_den_dbase%EOSProp(T,P,EOS_DENSITY,Rho,ierr)
863)
864) ! conversion to molar density
865) ! kg/m3 * kmol/kg = kmol/m3
866) Rho = Rho / fmw_oil ! kmol/m^3
867)
868) if (deriv) then
869) ! not yet implemented
870) ierr = 99 !error 99 points out that deriv are asked but not available yet.
871) print*, "EOSOilDensityDenDBase - Den derivatives not supported"
872) stop
873) end if
874)
875) end subroutine EOSOilDensityDenDBase
876)
877) ! ************************************************************************** !
878)
879) subroutine EOSOilDensityNoDerive(T,P,Rho,ierr)
880)
881) implicit none
882)
883) PetscReal, intent(in) :: T ! temperature [C]
884) PetscReal, intent(in) :: P ! pressure [Pa]
885) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
886) PetscErrorCode, intent(out) :: ierr
887)
888) PetscReal :: dum1, dum2
889)
890) ! derivatives are so cheap, just compute them
891) call EOSOilDensityPtr(T, P, PETSC_FALSE, Rho, dum1, dum2, ierr)
892)
893) end subroutine EOSOilDensityNoDerive
894)
895) ! ************************************************************************** !
896)
897) subroutine EOSOilDensityDerive(T,P,Rho,dRho_dT,dRho_dP,ierr)
898)
899) implicit none
900)
901) PetscReal, intent(in) :: T ! temperature [C]
902) PetscReal, intent(in) :: P ! pressure [Pa]
903) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
904) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
905) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
906) PetscErrorCode, intent(out) :: ierr
907)
908) call EOSOilDensityPtr(T,P,PETSC_TRUE,Rho,dRho_dT,dRho_dP,ierr)
909)
910) end subroutine EOSOilDensityDerive
911)
912) ! ************************************************************************** !
913)
914) subroutine EOSOilEnthalpyConstant(T,P,deriv,H,dH_dT,dH_dP,ierr)
915) implicit none
916) PetscReal, intent(in) :: T ! temperature [C]
917) PetscReal, intent(in) :: P ! pressure [Pa]
918) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
919) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
920) PetscReal, intent(out) :: dH_dT ! derivative enthalpy wrt temperature
921) PetscReal, intent(out) :: dH_dP ! derivative enthalpy wrt pressure
922) PetscErrorCode, intent(out) :: ierr
923)
924) H = constant_enthalpy ! J/kmol
925)
926) dH_dP = 0.d0
927) dH_dT = 0.d0
928)
929) end subroutine EOSOilEnthalpyConstant
930)
931) ! ************************************************************************** !
932)
933) subroutine EOSOilEnthalpyLinearTemp(T,P,deriv,H,dH_dT,dH_dP,ierr)
934) implicit none
935) PetscReal, intent(in) :: T ! temperature [C]
936) PetscReal, intent(in) :: P ! pressure [Pa]
937) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
938) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
939) PetscReal, intent(out) :: dH_dT ! derivative enthalpy wrt temperature
940) PetscReal, intent(out) :: dH_dP ! derivative enthalpy wrt pressure
941) PetscErrorCode, intent(out) :: ierr
942)
943) H = constant_sp_heat * T * fmw_oil ! J/(kg °C) °C * Kg/Kmol = J/Kmol
944)
945) dH_dT = UNINITIALIZED_DOUBLE
946) dH_dP = UNINITIALIZED_DOUBLE
947)
948) if (deriv) then
949) dH_dP = 0.d0
950) dH_dT = constant_sp_heat * fmw_oil
951) end if
952)
953) end subroutine EOSOilEnthalpyLinearTemp
954)
955) ! ************************************************************************** !
956)
957) subroutine EOSOilEnthalpyEOSDBase(T,P,deriv,H,dH_dT,dH_dP,ierr)
958) implicit none
959) PetscReal, intent(in) :: T ! temperature [C]
960) PetscReal, intent(in) :: P ! pressure [Pa]
961) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
962) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
963) PetscReal, intent(out) :: dH_dT ! derivative enthalpy wrt temperature
964) PetscReal, intent(out) :: dH_dP ! derivative enthalpy wrt pressure
965) PetscErrorCode, intent(out) :: ierr
966)
967) !ierr initialised in EOSEOSProp
968) call eos_dbase%EOSProp(T,P,EOS_ENTHALPY,H,ierr)
969)
970)
971) ! conversion to molar energy
972) ! J/kg * kg/Kmol = J/Kmol
973) H = H * fmw_oil
974)
975) dH_dT = UNINITIALIZED_DOUBLE
976) dH_dP = UNINITIALIZED_DOUBLE
977)
978) if (deriv) then
979) ! not yet implemented
980) ierr = 99 !error 99 points out that deriv are asked but not available yet.
981) print*, "EOSOilEnthalpyEOSDBase - H derivatives not supported"
982) stop
983) end if
984)
985) end subroutine EOSOilEnthalpyEOSDBase
986)
987) ! ************************************************************************** !
988)
989) subroutine EOSOilEnthalpyEntDBase(T,P,deriv,H,dH_dT,dH_dP,ierr)
990) implicit none
991) PetscReal, intent(in) :: T ! temperature [C]
992) PetscReal, intent(in) :: P ! pressure [Pa]
993) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
994) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
995) PetscReal, intent(out) :: dH_dT ! derivative enthalpy wrt temperature
996) PetscReal, intent(out) :: dH_dP ! derivative enthalpy wrt pressure
997) PetscErrorCode, intent(out) :: ierr
998)
999) !ierr initialised in EOSEOSProp
1000) call eos_ent_dbase%EOSProp(T,P,EOS_ENTHALPY,H,ierr)
1001)
1002)
1003) ! conversion to molar energy
1004) ! J/kg * kg/Kmol = J/Kmol
1005) H = H * fmw_oil
1006)
1007) dH_dT = UNINITIALIZED_DOUBLE
1008) dH_dP = UNINITIALIZED_DOUBLE
1009)
1010) if (deriv) then
1011) ! not yet implemented
1012) ierr = 99 !error 99 points out that deriv are asked but not available yet.
1013) print*, "EOSOilEnthalpyEntDBase - H derivatives not supported"
1014) stop
1015) end if
1016)
1017) end subroutine EOSOilEnthalpyEntDBase
1018)
1019) ! ************************************************************************** !
1020)
1021) subroutine EOSOilEnthalpyNoDerive(T,P,H,ierr)
1022) implicit none
1023) PetscReal, intent(in) :: T ! temperature [C]
1024) PetscReal, intent(in) :: P ! pressure [Pa]
1025) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
1026) PetscErrorCode, intent(out) :: ierr
1027)
1028) PetscReal :: dum1, dum2
1029)
1030) call EOSOilEnthalpyPtr(T,P,PETSC_FALSE,H,dum1,dum2,ierr)
1031)
1032) end subroutine EOSOilEnthalpyNoDerive
1033)
1034) ! ************************************************************************** !
1035)
1036) subroutine EOSOilDensityEnergyTOilIms(T,P,deriv,Rho,dRho_dT,dRho_dP, &
1037) H,dH_dT,dH_dP,U,dU_dT,dU_dP,ierr)
1038) implicit none
1039)
1040) PetscReal, intent(in) :: T ! temperature [C]
1041) PetscReal, intent(in) :: P ! pressure [Pa]
1042) PetscBool, intent(in) :: deriv ! indicate if derivatives are needed or not
1043) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
1044) PetscReal, intent(out) :: dRho_dT ! derivative oil density wrt temperature
1045) PetscReal, intent(out) :: dRho_dP ! derivative oil density wrt pressure
1046) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
1047) PetscReal, intent(out) :: dH_dT ! derivative enthalpy wrt temperature
1048) PetscReal, intent(out) :: dH_dP ! derivative enthalpy wrt pressure
1049) PetscReal, intent(out) :: U ! internal energy [J/kmol]
1050) PetscReal, intent(out) :: dU_dT ! deriv. internal energy wrt temperature
1051) PetscReal, intent(out) :: dU_dP ! deriv. internal energy wrt pressure
1052) PetscErrorCode, intent(out) :: ierr
1053)
1054) call EOSOilDensityPtr(T,P,deriv,Rho,dRho_dT,dRho_dP,ierr)
1055) call EOSOilEnthalpyPtr(T,P,deriv,H,dH_dT,dH_dP,ierr)
1056)
1057) U = H - P/Rho
1058)
1059) dU_dT = UNINITIALIZED_DOUBLE
1060) dU_dP = UNINITIALIZED_DOUBLE
1061)
1062) if (deriv) then
1063) print*, "EOSOilDensityEnergyTOilIms - U derivatives not supported"
1064) stop
1065) end if
1066)
1067)
1068) end subroutine EOSOilDensityEnergyTOilIms
1069)
1070) ! ************************************************************************** !
1071)
1072) subroutine EOSOilDenEnergyNoDerive(T,P,Rho,H,U,ierr)
1073)
1074) implicit none
1075)
1076) PetscReal, intent(in) :: T ! temperature [C]
1077) PetscReal, intent(in) :: P ! pressure [Pa]
1078) PetscReal, intent(out) :: Rho ! oil density [kmol/m^3]
1079) PetscReal, intent(out) :: H ! enthalpy [J/kmol]
1080) PetscReal, intent(out) :: U ! internal energy [J/kmol]
1081) PetscErrorCode, intent(out) :: ierr
1082)
1083) PetscReal :: dum1, dum2, dum3, dum4, dum5, dum6
1084)
1085) call EOSOilDensityEnergyPtr(T,P,PETSC_FALSE,Rho,dum1,dum2, &
1086) H,dum3,dum4,U,dum5,dum6,ierr)
1087)
1088)
1089) end subroutine EOSOilDenEnergyNoDerive
1090)
1091) ! **************************************************************************** !
1092)
1093) subroutine EOSOilInputRecord()
1094) !
1095) ! Prints ingested equation of state information to the input record file.
1096) !
1097) ! Author: Jenn Frederick
1098) ! Date: 05/04/2016
1099) !
1100)
1101) implicit none
1102)
1103) character(len=MAXWORDLENGTH) :: word1, word2
1104) character(len=MAXSTRINGLENGTH) :: string
1105) PetscInt :: id = INPUT_RECORD_UNIT
1106)
1107) write(id,'(a29)',advance='no') '---------------------------: '
1108) write(id,'(a)') 'OIL'
1109)
1110) write(id,'(a)') 'EOSOilInputRecord not implemented: &
1111) &Email jmfrede@sandia.gov for more information if using &
1112) &OIL modes and EOS information is wanted.'
1113)
1114) write(id,'(a)') '---------------------------------------------------------&
1115) &-----------------------'
1116)
1117) end subroutine EOSOilInputRecord
1118)
1119) ! ************************************************************************** !
1120) subroutine EOSOilDBaseDestroy()
1121)
1122) implicit none
1123)
1124) call EOSDatabaseDestroy(eos_dbase)
1125) call EOSDatabaseDestroy(eos_den_dbase)
1126) call EOSDatabaseDestroy(eos_ent_dbase)
1127) call EOSDatabaseDestroy(eos_vis_dbase)
1128)
1129) end subroutine EOSOilDBaseDestroy
1130)
1131) ! ************************************************************************** !
1132)
1133) end module EOS_Oil_module