import os
from mako.template import Template
#==================================== DENSITIES =======================================
# =================================== COOLANT =======================================
def N_water(z) : # return number of molecules of water [molecule/cm3] in tvs assembly at position z [cm]
Na = 0.6022140857 #a vogadro's number [molecule/mole] * 1E-24
Mw = 18
return (Na * (3E-6 * z ** 3 + 1E-5 * z ** 2 - 0.2833 * z + 709.36) / (Mw * 1000))
def N_Hw(z) : # return number of H [atom/cm3] in water in tvs assembly at position z [cm]
return (2 * N_water(z))
def N_Ow(z): # return number of O [atom/cm3] in water in tvs assembly at position z [cm]
return (N_water(z))
N_HW=[]
for z in range(-185,186):
N_HW.append(round(N_Hw(z),6))
N_OW=[]
for z in range(-185,186):
N_OW.append(round(N_Ow(z),6))
# =================================== CLAD OF FUEL, ALLOY E110 ===========================
# ================================ also Central channel and Regulation channel alloy E635=======
def N_Zrf(z) : # return number of molecules of Zr clad [molecule/cm3] in tvs assembly at position z [cm]
Na = 0.6022140857
Mzr= 91.224
return (Na * (2E-07 * z**3 + 0.0002 * z**2 - 0.0176 * z + 6504.1) / (Mzr * 1000))
def N_Nbf(z):
return (0.01 * N_Zrf(z))
N_ZRF=[]
for z in range(-185,186):
N_ZRF.append(round(N_Zrf(z),6))
N_NBF=[]
for z in range(-185,186):
N_NBF.append(round(N_Nbf(z),6))
#================================ Gap of Helium =================================================
def N_He(z):
Na= 0.6022140857
MHe= 4
return(Na * (0.0009 * z**2 - 0.0718 * z + 5.8319) / (MHe *1000) )
N_HE=[]
for z in range(-185,186):
N_HE.append(round(N_He(z),6))
# ================================== FUEL =======================================
# ================================== 300 TVEL 3.554 % ENRICHED UO2 ================================
def N_UO2(z): # return number of molecules of UO2 in fuel [molecule/cm3] at position z [cm]
Na = 0.6022140857
Muo2= 270.03
return (Na * (-2E-08 * z**4 + 4E-07 * z**3 + 0.0023 * z**2 - 0.0182 * z+ 10030) / (Muo2 * 1000))
def N_U235(z): # return number of U235 atoms [atom/cm3] in fuel element at position z [cm]
Mu235 = 235
Mu = 270.03
row = 0.03554
return (row * N_UO2(z) * Mu / Mu235)
def N_U238(z): # return number of u238 atoms [atom/cm3] in fuel element at position z [cm]
return (N_UO2(z) - N_U235(z))
def N_Ofl(z): # return number of O atoms [atom/cm3] in fuel element at position z [cm]
return (2* N_UO2(z))
N_U235L=[]
for z in range(-185,186):
N_U235L.append(round(N_U235(z),6))
N_U238L=[]
for z in range(-185,186):
N_U238L.append(round(N_U238(z),6))
N_OFL=[]
for z in range(-185,186):
N_OFL.append(round(N_Ofl(z),6))
# ================================== 12 TVEG 2.4% ENRICHED UO2 MIXED WITH 8% Gd2O3 ===============
def N_UO2g(z): # return number of molecules of UO2 in tveg [molecule/cm3] at position z [cm]
Na = 0.6022140857
Muo2= 270.03
x_uo2=0.935 # mole fraction of UO2
return (x_uo2 * Na * (-2E-08 * z**4 + 3E-07 * z**3 + 0.0023 * z**2 - 0.018 * z + 9935.5) / (Muo2 * 1000))
def N_Gd2O3(z) : # return number of molecules of gd2o3 in tveg [molecule/cm3] at position z [cm]
Na = 0.6022140857
Mgd2o3= 362.5
x_uo2=0.935 # mole fraction of UO2
x_gd2o3=1-x_uo2 # mole fraction of Gd2O3
return (x_gd2o3 * Na * (-2E-08 * z ** 4 + 3E-07 * z ** 3 + 0.0023 * z ** 2 - 0.018 * z + 9935.5) / (Mgd2o3 * 1000))
def N_U235g(z): # return number of U235 atoms [atom/cm3] in tveg at position z [cm]
Mu235 = 235
Mu = 238.02891
row = 0.024
return (row * N_UO2g(z) * Mu / Mu235)
def N_U238g(z): # return number of u238 atoms [atom/cm3] in tveg at position z [cm]
return (N_UO2g(z) - N_U235(z))
def N_Gd(z) : # return number of Gd atoms [atom/cm3] in tveg at position z [cm]
return ( 2 * N_Gd2O3(z))
def N_Gd57(z) :
x_Gd=0.1565
return (x_Gd * N_Gd(z))
def N_Ofg(z): # return number of O atoms [atom/cm3] in tveg at position z [cm]
return (( 2 * N_UO2g(z) ) + ( 3 * N_Gd2O3(z)))
N_U235G=[]
for z in range(-185,186):
N_U235G.append(round(N_U235g(z),6))
N_U238G=[]
for z in range(-185,186):
N_U238G.append(round(N_U238g(z),6))
N_GD57=[]
for z in range(-185,186):
N_GD57.append(round(N_Gd57(z),6))
N_OFG=[]
for z in range(-185,186):
N_OFG.append(round(N_Ofg(z),6))
# ============================== control rod absorption material B4C + Dy2TiO5 ==================
Na = 0.6022140857
Mb4c= 55.255
row_b4c = 1700
N_B4C= Na * row_b4c * 0.001 /Mb4c
x_b10=0.199
N_B10= x_b10 * 4 * N_B4C
N_C= N_B4C
Mdy2tio5 = 452.9
N_Dy2TiO5=Na * 4900 * 0.001/ Mdy2tio5 # return number of molecules of Dy2TiO5 in Control rod [molecule/cm3]
N_Dy= 2 * N_Dy2TiO5
N_Ti= N_Dy2TiO5
N_Oc= 5 * N_Dy2TiO5
N_B10C=[round(0.0000001,6)]*140
N_B10C.extend([round(N_B10,6)]*45) # 20% of active core height - 30 cm of Dy2TiO5
N_HC=[]
for z in range(-185,112):
N_HC.append(round(N_Hw(z),6))
N_HC.extend([0.0]*74) # when conrol rod is 20% of active core length, the rest of the channel is filled
# with water
N_OCW=[]
for z in range(-185,112):
N_OCW.append(round(N_Ow(z),6))
N_OCW.extend([0.0]*74)
N_CC=[round(0.0000001,6)]*140
N_CC.extend([round(N_C,6)]*45)
N_DY=[round(0.0000001,6)]*110
N_DY.extend([round(N_Dy,6)]*30)
N_DY.extend([round(0.0000001,6)]*45)
N_TI=[round(0.0000001,6)]*110
N_TI.extend([round(N_Ti,6)]*30)
N_TI.extend([round(0.0000001,6)]*45)
N_OC=[round(0.0000001,6)]*110
N_OC.extend([round(N_Oc,6)]*30)
N_OC.extend([round(0.0000001,6)]*45)
# =============================== CONTROL ROD CLADDING, ALLOY 42XHM ===========================
Na = 0.6022140857
Mni = 58.7
Mcr = 52
row_42xnm = 8
x_ni = 0.55
x_cr = 0.42
N_Ni= x_ni * Na * row_42xnm * 2 / (Mni + Mcr)
N_Cr= x_cr * Na * row_42xnm * 2 / (Mni + Mcr)
N_NI=[round(N_Ni,6)]*370
N_CR=[round(N_Cr,6)]*370
input_template_dir = r"C:\Users\mike\Desktop\VVER\tvs82\inputgetera82.inp"
getera_dir = r"C:\Users\mike\Desktop\VVER\GETERA"
cfg_dir = os.path.join(getera_dir, r"bin\config.get")
cfg_templ_dir = os.path.join(getera_dir, r"cfg.mako")
inp_templ = Template(filename = input_template_dir)
cfg_templ = Template(filename = cfg_templ_dir)
for h in range(0, 370):
inp_dir = os.path.join(getera_dir, r"input\VVER_{0}.inp".format(h))
out_dir = os.path.join(getera_dir, r"input\VVER_{0}.out".format(h))
with open(cfg_dir, "w") as f:
f.write(cfg_templ.render(inp_dir=inp_dir, out_dir=out_dir))
with open(inp_dir, "w") as f:
f.write(inp_templ.render(NHW[h],N_HW[h]))
os.system(r"C:\Users\mike\Desktop\VVER\GETERA\bin\getera.exe")
Error:
C:\Python36\python.exe C:/Users/mike/Desktop/VVER/tvs82/densities82.py
Traceback (most recent call last):
File "C:/Users/mike/Desktop/VVER/tvs82/densities82.py", line 179, in <module>
f.write(inp_templ.render(NHW[h],N_HW[h]))
IndexError: list index out of range
Process finished with exit code 1
Quote:there are 20 lists i need to render into the template
Quote:i am new in python, i am just using it to create input file for another code