Skip to content

Adding generators example

acroucher edited this page Sep 24, 2014 · 5 revisions

This example PyTOUGH script opens a geometry file and TOUGH2 data file and assigns uniformly distributed heat generators over a circular region of the basement of the model (within a specified radius of the centre of the upflow).

geo = mulgrid('gmodel.dat')
dat = t2data('model.dat')

upflow_centre = np.array([15000., 21000.])
upflow_radius = 1200.
totalheat = 10.e6

layer = geo.layerlist[-1]  # bottom layer
cols = [col for col in geo.columnlist if 
        np.linalg.norm(col.centre - upflow_centre) <= upflow_radius]
totalarea = sum([col.area for col in cols])
q = totalheat / totalarea

dat.clear_generators()
for col in cols:
    blockname = geo.block_name(layer.name, col.name)
    gen = t2generator(name = ' q' + col.name, block = blockname,
                      type = 'HEAT', gx = q * col.area)
    dat.add_generator(gen)

dat.write()

Here the numpy function linalg.norm is used to calculate the distance between each column centre and the centre of the upflow, to see if it lies within the upflow region.

Clone this wiki locally