PyTOUGH: failing to write the GENER data block when the grid is defined with naming convention '0'
Hi there,
Cc. Adrian Croucher
I've been trying to replicate a PyTOUGH example to set a heat flow boundary condition at the bottom of a 3D domain. Things work ok when my mulgrid object is based on naming convention 1 or 2. If I use naming convention 0 however, the t2data funcion 'write' is unable to write the data block GENER. I get an error related with the name of the grid blocks, a data type error.
This short code for example succeeds to write the file 'flow.inp' if naming conventions 1 or 2 are set, but doesn't for convention 0.
Does anyone have an idea on why this happens? Even tough one can simply stick to conventions 1 or 2, convention 0 may be useful in larger domains.
Many thanks
Fernando
-------------------------------------
from mulgrids import *
from t2grids import *
from t2data import *
geo=mulgrid().rectangular([20]*6,[20]*8,[10]*4, convention=2, atmos_type=1, origin=[0,0,0], justify='r', case=None, chars=ascii_lowercase)
#TOUGH2 geometry
t2geo=t2grid().fromgeo(geo)
#TOUGH2 data
dat=t2data()
#============== generators ===============
bly=geo.layerlist[-1] # bottom layer
cols=[col for col in geo.columnlist]
q=90.E-3
for col in cols:
blockname = geo.block_name(bly.name, col.name)
gen = t2generator(name =' q'+col.name, block = blockname, type ='HEAT', gx = q*col.area)
dat.add_generator(gen)
dat.write('flow.inp')
2 replies
-
hi Fernando, the problem here is that the name you give to your generator must also match the naming convention of the blocks. So if you want to use convention 0 (3 chars for column, 2 digits for layer) your generator name must also have 3 chars followed by 2 digits. If you use e.g. "name = col.name + '99'" then it will work with convention 0.
-
Hi Adrian,
Thank you for your time. You are right, I missed TOUGH expects two digits at the end of the generator name, and 'col.name' in convention 0 are characters! Your suggestion works.
Best,
Fernando