Droplet Lagrangian Transient One-dimensional Reacting Code Implementation of both liquid and gas phase governing equations.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 7 mēnešiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Mon Mar 25 14:37:01 2024
  5. @author: david
  6. """
  7. #!/usr/bin/env python3
  8. # -*- coding: utf-8 -*-
  9. """
  10. Created on Wed Feb 14 14:39:59 2024
  11. @author: wangweiye
  12. """
  13. import numpy as np
  14. from numpy import power
  15. import cantera as ct
  16. import matplotlib.pyplot as plt
  17. from scipy.interpolate import CubicHermiteSpline
  18. font = {'family':'times',
  19. 'color':'darkred',
  20. 'weight':'normal',
  21. 'size':16}
  22. def calVaporPressure(T:float) ->float :
  23. # return 1e5*np.power(10,4.6543 - (1435.264/(T - 64.84))) # returns Pa, where T is in K
  24. #P = 1e3*np.exp(16.7 - (4060.0/(T - 37.0))) # returns Pa, where T is in K,FOR WATER
  25. #P = 1e5*np.power(10,4.02832-(1268.636/(T-56.199))) ; #FOR N-HEPTANE
  26. P = 0.00 #NO FUEL @ t0
  27. return P
  28. # return 1D numpy array for liquid phase mass fraction
  29. def genLiquidMassFracArr(gas,dropTemp:float,P:float,dropSpec:str) :
  30. gas.TPX = dropTemp,P,dropSpec
  31. massArr_ = gas.Y
  32. # print(gas.Y)
  33. return massArr_
  34. # return 1D numpy array for gas phase mass fraction
  35. def genGasMassFracArr(gas,gasTemp:float,P:float,gasSpec:str):
  36. gas.TPX = gasTemp,P,gasSpec
  37. massArr_ = gas.Y
  38. return massArr_
  39. # return 1D numpy array for gas phase spatial coordinate and temperature
  40. def genGasTempAndRadiusArr(Rd,L,shift,Wmix,nPts,dropTemp,gasTemp,deltaT):
  41. dX = L/(nPts-1)
  42. r_ = np.zeros(nPts)
  43. r_[0] = Rd
  44. #DEBUG
  45. #print("r_[0] = %15.6e\n"%(r_[0]))
  46. for ii in range(1, nPts-1):
  47. r_[ii] = r_[ii-1] + dX
  48. r_[nPts-1] = Rd+L
  49. x = [Rd+shift, Rd+shift+Wmix] ;
  50. y = [dropTemp+deltaT, gasTemp] ;
  51. m = [0,0] ;
  52. spline = CubicHermiteSpline(x, y, m)
  53. T_ = np.zeros(nPts)
  54. for i in range(nPts):
  55. if r_[i] <= Rd :
  56. T_[i] = dropTemp ;
  57. if r_[i] > Rd and r_[i] < (Rd+shift):
  58. T_[i] = dropTemp + deltaT ;
  59. if r_[i] >= (Rd + shift) and (r_[i] <= Rd + shift + Wmix) :
  60. T_[i] = spline(r_[i]) ;
  61. if r_[i] > (Rd + shift +Wmix) and r_[i] <= (Rd+L) :
  62. T_[i] = gasTemp ;
  63. return r_,T_
  64. # return 2D numpy array with size of (nvar*nPts)
  65. def writeGlobalArr(Rd,L,shift,Wmix,dropTemp,gasTemp,deltaT,P,dropSpec,gasSpec,gas,lnPts,gnPts,fileName):
  66. liquidMassFracArr_ = genLiquidMassFracArr(gas, dropTemp, P, dropSpec)
  67. gasMassFracArr_ = genGasMassFracArr(gas, gasTemp, P, gasSpec)
  68. # assign spatial coordinate value
  69. rG_,TG_ = genGasTempAndRadiusArr(Rd, L, shift, Wmix, gnPts, dropTemp, gasTemp,deltaT)
  70. rL_ = np.zeros(lnPts)
  71. dXL = Rd/(lnPts-1)
  72. rL_[0] = 0.0
  73. for ii in range(1, lnPts-1):
  74. rL_[ii] = rL_[ii-1] + dXL
  75. rL_[lnPts-1] = Rd
  76. #DEBUG
  77. # print("last element of rL_ is :%15.6e"%(rL_[lnPts-1]))
  78. # print("first element of rG_ is :%15.6e"%(rG_[0]))
  79. r_ = np.concatenate((rL_,rG_))
  80. # assign temperature values
  81. TL_ = np.ones(lnPts)*dropTemp
  82. T_ = np.concatenate((TL_,TG_))
  83. # assign pressure values
  84. P_ = np.ones(gnPts+lnPts) * P
  85. mdot_ = np.ones(gnPts+lnPts) * 0.0
  86. # write global arr to output file
  87. out=open(fileName,"w")
  88. for i in range(lnPts):
  89. out.write("%15.6e\t%15.6e\t"%(r_[i],T_[i]))
  90. for j in range(gas.n_species):
  91. out.write("%15.6e\t"%(liquidMassFracArr_[j]))
  92. out.write("%15.6e\t"%(P_[i]))
  93. out.write("%15.6e\n"%(mdot_[i]))
  94. for i in range(lnPts,lnPts+gnPts):
  95. out.write("%15.6e\t%15.6e\t"%(r_[i],T_[i]))
  96. for j in range(gas.n_species):
  97. out.write("%15.6e\t"%(gasMassFracArr_[j]))
  98. out.write("%15.6e\t"%(P_[i]))
  99. out.write("%15.6e\n"%(mdot_[i]))
  100. out.close()
  101. # =============================================================================
  102. # Following block defines the user defined parameters
  103. # =============================================================================
  104. if __name__ == "__main__" :
  105. fileName = "initialConditionTest.dat" #This script output the initial conditions
  106. #mech='sdMechMergedVer2.cti'
  107. mech='redKaust-C3.xml' #Mechanism name
  108. #mech='chem171.cti'
  109. gas = ct.Solution(mech)
  110. Rd = 200.0e-6 #droplet radius, Unit:[m]
  111. domainLength = Rd*50.0 #domain length, Unit:[m]
  112. shift = Rd * 3.0e0 #shift of mixing region from droplet surface
  113. Wmix = Rd * 5.0e0 #thickness of mixing layer for heptane mass fraction & Temperature distribution, Unit:[m]
  114. gNpts = 5000 #Number of grid points in gas phase
  115. lNpts = 500 #Number of grid points in liquid phase
  116. Tamb = 1400.00 #Temperature of ambient air, Unit : [K]
  117. Pamb = 20.0*ct.one_atm #Pressure of ambient air, Unit :[Pa]
  118. Td = 310.00 #Temperature of droplet surface, Unit: [K]
  119. deltaT = 20.0
  120. #RH = 0.0 #relative humidity
  121. #dropName = "NC7H16:0.80,C3H8:0.20" #Name of droplet species
  122. dropName ="NC7H16:1.00"
  123. gasComposition = "O2:0.21,N2:0.79"
  124. writeGlobalArr(Rd, domainLength, shift, Wmix, Td, Tamb,deltaT, Pamb, dropName, gasComposition, gas, lNpts, gNpts, fileName)
  125. # writeGlobalArr(Rd, L, shift, Wmix, dropTemp, gasTemp, P, dropSpec, gasSpec, gas, lnPts, gnPts, fileName)
  126. #writeInitCond(Rd, domainLength, shift, Wmix, nGrid, Tamb, Pamb, Td, RH, gas, dropName, oxidizerName, bathName, fileName)
  127. # genTotalMassfracArr(Rd, domainLength, shift, Wmix, nGrid, Tamb, Pamb, Td, RH, gas, dropName, oxidizerName, bathName)
  128. # genTemArr(Rd, domainLength, shift, Wmix, nGrid, Tdrop, Tamb)
  129. # genMolefracArr(Rd, domainLength, shift, Wmix, nGrid, Tamb, Pamb, Td, RH)