Initial Condition Calculation
def iniCondition(double_array, int_array):
# start getting data section, user does not need change to this section
nPrv=int_array[4] #this is the number of primary variables
numElem=int_array[6] #number of elements
HEAT=int_array[7]-1 # the index of temperature in the PV list
xk= np.zeros((numElem, nPrv), dtype='float64') # original primary variables
xx= np.zeros(numElem*(nPrv+1), dtype='float64') # final primary variables
x= np.zeros(numElem, dtype='float64') # x coordinates
y= np.zeros(numElem, dtype='float64') # y coordinates
z= np.zeros(numElem, dtype='float64') # z coordinates
nMat=np.zeros(numElem, dtype=int) # rock index of the elements
stateIdx=np.zeros(numElem, dtype=int) # phase state index
for i in range(0,nPrv):
nE=i*numElem
for j in range(0,numElem):
xk[j,i]=double_array[nE+j] # get original initial-condition PV variables.
nE=nPrv*numElem
for i in range(0,numElem):
x[i]= double_array[nE+i] # get x coordinates
nE=nE+numElem
for i in range(0,numElem):
y[i]= double_array[nE+i] # get y coordinates
nE=nE+numElem
for i in range(0,numElem):
z[i]= double_array[nE+i] # get z coordinates
for i in range(0,numElem):
nMat[i]= int_array[i+10] # get rock of the elements.
for i in range(0,numElem):
stateIdx[i]= int_array[i+10+numElem] # get initial phase state index
# end getting data section
# users need to define the reference temperature and pressure:
refZ=0
refT=35.0
refP=5.0e6
density=1000.0
g=9.81
T_gradient=35.0 # temperature gradient 35C/km
# perform calculation of xk (PV for initial condition) at following lines:
# for example, pressure: if gravity equilibrium, xk=P_ref+density*g*h
# temperature: geothermal temperature graditent is known: xk(HEAT)=T_ref-h*T_gradient
# User can assign the the primary variables based on knowns: such as: x, y, z, nMat
for i in range(0,numElem):
xk[i,0]=refP+(z[i]-refZ)*density*g
# xk[i,1]=0.000
# xk[i,2]=0.000
xk[i,HEAT]=refT+(z[i]-refZ)/1000.0*T_gradient
# stateIdx[i]=2 #Users can also change the phase state if necessary
#start assembling data section, user does not need change to this section
for i in range(0,nPrv):
nE=i*numElem
for j in range(0,numElem):
xx[nE+j] =xk[j,i]
nE= nPrv*numElem
for j in range(0,numElem):
xx[nE+j] = stateIdx[j]
# assembling data section
return xx Last updated