Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. from fipy import Variable, FaceVariable, CellVariable, Grid1D, ExplicitDiffusionTerm, TransientTerm, DiffusionTerm, Viewer
  2. from fipy.tools import numerix
  3. import numpy as np
  4. import pandas as pd
  5.  
  6.  
  7. nx = 6000 #amount of steps
  8. dx = 1. #stepsize
  9. L = int(nx * dx) #depth of well
  10.  
  11. mesh = Grid1D(nx=nx, dx=dx)
  12. m = Grid1D(nx=1., dx=0.1)
  13.  
  14.  
  15.  
  16.  
  17. T = CellVariable(name="temp vs depth DH4", mesh=mesh, value= (mesh.cellCenters[0]) / 75)
  18. X = mesh.faceCenters[0]
  19.  
  20.  
  21.  
  22. toyr = 60 * 60 * 24 * 365 #to year from s
  23.  
  24. #variables into FaceVariables
  25. k= FaceVariable(mesh=mesh)
  26. dens= FaceVariable(mesh=mesh)
  27. cp = FaceVariable(mesh=mesh)
  28.  
  29.  
  30.  
  31. k.setValue(0)
  32. dens.setValue(0)
  33. cp.setValue(0)
  34.  
  35. #df.D.iloc[ii]
  36.  
  37. for ii in range(len(df.d)):
  38. if df.lithology.iloc[ii] == 'sandstone':
  39. k.setValue(3 * toyr, where=(X == ii))
  40. dens.setValue(2200, where=(X == ii))
  41. cp.setValue(850, where=(X == ii))
  42. elif df.lithology.iloc[ii] == 'shale/siltstone':
  43. k.setValue(2 * toyr, where=(X == ii))
  44. dens.setValue(2400, where=(X == ii))
  45. cp.setValue(850, where=(X == ii))
  46. elif df.lithology.iloc[ii] == 'ign_intrusion':
  47. k.setValue(2 * toyr, where=(X == ii))
  48. dens.setValue(2700, where=(X == ii))
  49. cp.setValue(850, where=(X == ii))
  50. elif df.lithology.iloc[ii] == 'shale':
  51. k.setValue(2 * toyr, where=(X == ii))
  52. dens.setValue(2600, where=(X == ii))
  53. cp.setValue(850, where=(X == ii))
  54.  
  55.  
  56. D = k / (dens * cp)
  57. #find a way to apply different densities to D
  58.  
  59.  
  60. time = Variable()
  61.  
  62.  
  63. fluxRight = 0.1 #UNIT' heatflow influx
  64. T.faceGrad.constrain([fluxRight], mesh.facesRight)
  65.  
  66.  
  67. eqI = TransientTerm() == DiffusionTerm(coeff=D)
  68.  
  69.  
  70. if __name__ == '__main__':
  71. viewer = Viewer(vars=(T), limits={'xmin': 0, 'xmax': 6000, 'ymin':-15, 'ymax':250} )
  72. viewer.plot()
  73.  
  74.  
  75. D = FaceVariable(mesh=mesh, value=D)
  76.  
  77. dt = 1
  78.  
  79. while time() < 1500:
  80. if surface_temp.value.iloc[time] == 1:
  81. valueLeft = 0
  82. T.constrain(valueLeft, mesh.facesLeft)
  83. elif surface_temp.value.iloc[time] == 2:
  84. valueLeft = -5
  85. T.constrain(valueLeft, mesh.facesLeft)
  86. elif surface_temp.value.iloc[time] == 3:
  87. valueLeft = -15
  88. T.constrain(valueLeft, mesh.facesLeft)
  89. #here add the temperature of -6 which is the CMR approximation for the
  90. #surface temp 150000 - 800000 yrs ago
  91.  
  92. time.setValue(time() + dt)
  93. eqI.solve(var=T, dt=dt)
  94. if __name__ == '__main__':
  95. viewer.plot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement