acroucher / PyTOUGH

A Python library for automating TOUGH2 simulations of subsurface fluid and heat flow
GNU Lesser General Public License v3.0
96 stars 36 forks source link

problem to write a VTK file using the radial exemple #22

Closed aaamri closed 4 years ago

aaamri commented 4 years ago

hi Adrien, I'm trying to run the example 'radial model' but i have a problem that i didn't succed to fix it :

AttributeError Traceback (most recent call last)

in 34 dat.add_generator(gen) 35 dat.write('radial.dat') ---> 36 dat.grid.write_vtk(dat.grid, 'INFILE.vtu') 37 # run the simulation: 38 #dat.run(simulator = 't2eos1') ~\Anaconda2\lib\site-packages\t2grids.py in write_vtk(self, geo, filename, wells, blockmap, surface_snap) 557 from vtk import vtkXMLUnstructuredGridWriter 558 if wells: geo.write_well_vtk() --> 559 arrays = geo.get_vtk_data(blockmap) 560 grid_arrays = self.get_vtk_data(geo, blockmap) 561 for array_type, array_dict in arrays.items(): ~\Anaconda2\lib\site-packages\t2grids.py in get_vtk_data(self, geo, blockmap) 522 string_properties = ['Name'] 523 string_length = 5 --> 524 nele = geo.num_underground_blocks 525 array_length = {'Block': nele, 'Node': 0} 526 for array_type, array_dict in arrays.items(): AttributeError: 'dict' object has no attribute 'num_underground_blocks' Can you please tell me the source of this problem, Thanks ! ​
acroucher commented 4 years ago

In your line 36 you have dat.grid.write_vtk(dat.grid, 'INFILE.vtu'). The first argument of t2grid.write_vtk() should be a mulgrid geometry, not a t2grid. If you are basing your script on the one in the PyTOUGH wiki, that example does not actually create a mulgrid geometry. That's because it is a one-dimensional problem, and a 3-D mesh geometry is not needed. You could still create one using mulgrid.rectangular(), using the radial mesh sizes as the x grid sizes and assigning a single fixed mesh size in the y and z directions. That would allow you to do a quasi-3D visualisation. But the example script just plots results on line plots, because it is fundamentally a 1-D problem.

aaamri commented 4 years ago

Thanks acroucher for explaining the difference between the mulgrid and the T2grid, i followed Your proposition, but i finish by generate a rectangular mesh, and i'm trying to genrate a 3-D cylinder mesh ( 2D axisymmetric).? can you see a way to do it ?? image

acroucher commented 4 years ago

You can create a TOUGH2 grid in cylindrical coordinates also using t2grid.radial(). You just pass in a list or array of vertical block sizes as the zblocks parameter. But you can't easily create VTK output that looks like what you have in the figure above. To me, that is not a very useful way to visualise a model in cylindrical coordinates, because the results will be exactly the same in each 'ring' of blocks at a given radius, due to the radial symmetry. I think it is more useful to visualise such a model using a 2-D plot in r-z coordinates, since the model is in fact 2-D, not 3-D.