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

Plot Static 3D Mesh from .dat File #54

Open pierecnlnd opened 8 months ago

pierecnlnd commented 8 months ago

I am seeking to read a .dat file and visualize the mesh static data in actual x, y, and z coordinates. Are there any built-in methods available in PyTough that I can utilize for this purpose?

acroucher commented 7 months ago

Yes, but you will need a mulgrid geometry file for your mesh. Then you can do 2D layer or slice visualization of any quantity using the mulgrid layer_plot() and slice_plot() methods, or export to VTK files for 3D visualization.

pierecnlnd commented 7 months ago

Thank you, sir. Actually, I am still learning to use mulgrid but I already use software like Petrasim to create grid geometry. Is there any methods that you can recommend to convert either from mulgrid to .dat (Petrasim) or vice versa?

acroucher commented 7 months ago

If by ".dat" you mean the TOUGH2 input data file, then PyTOUGH does have methods for converting between .dat and mulgrid. If you have a mulgrid geometry you can use the t2grid.fromgeo() method to create the grid inside the .dat file. If you have a .dat file you can reverse-engineer a mulgrid geometry using the t2grid.rectgeo() method, but only if your grid is rectangular.

medhay36 commented 7 months ago

If by ".dat" you mean the TOUGH2 input data file, then PyTOUGH does have methods for converting between .dat and mulgrid. If you have a mulgrid geometry you can use the t2grid.fromgeo() method to create the grid inside the .dat file. If you have a .dat file you can reverse-engineer a mulgrid geometry using the t2grid.rectgeo() method, but only if your grid is rectangular.

Hello dear Adrian,

Can you please give us the full syntax of 't2grid.rectgeo()' ? My TOUGH2 input data file is named INFILE.dat

I tried the following syntax but got errors dat.grid=t2grid().rectgeo(origin_block =None, atmos_volume =1.e25, remove_inactive =True, atmos_type =2, justify ='r',spaces =True, layer_snap =0.1, block_order =None,convention = 2, chars = ascii_lowercase + ascii_uppercase)

acroucher commented 6 months ago

That syntax looks ok. The obvious thing that can go wrong with rectgeo() is that the grid is not actually rectangular (e.g. it has areas of local refinement). What kind of errors did you get?

medhay36 commented 6 months ago

That syntax looks ok. The obvious thing that can go wrong with rectgeo() is that the grid is not actually rectangular (e.g. it has areas of local refinement). What kind of errors did you get?

Hello Adrian,

this is the most revealant error i encounter

ValueError: All-NaN slice encountered

image

acroucher commented 6 months ago

It looks like maybe your input file doesn't have block centres in the grid? You will definitely need those before you can make a geometry from it.