acroucher / PyTOUGH

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

dat.run() #57

Open jousheinfo opened 3 weeks ago

jousheinfo commented 3 weeks ago

Hello,

I have a TOUGH input file, and I would like to run it through PyTOUGH to get the listing file. The code I have is the following:

from t2data import * dat = t2data('file.inp') dat.run(simulator = 'tough3_eco2m.exe')

I get the following Python error: :15: SyntaxWarning: invalid escape sequence '\P'

It kinda generates the listing file, but I get the following error: TOUGH ERROR: Please check the name of the input file specified or rename input file to INFILE

I have the CO2TAB, executable and input files saved in the same folder. I tried to rename the input file, but I still get the same error. I kindly ask for your support, please. Thanks!.

jousheinfo commented 3 weeks ago

@acroucher the comments above seem to be suspicious. Please take action. Looking forward to your response. Thanks!

acroucher commented 3 weeks ago

PyTOUGH's t2data.run() method hasn't really been tested with TOUGH3, but I gather that in theory it should work much the same as TOUGH2. Have you tested running it outside of Python, i.e. just running on the command line tough3_eco2m.exe < file.inp > output.listing or similar?

I don't know what the "invalid escape sequence" message is about, but the error after that suggests that TOUGH3 just can't find the input file.

jousheinfo commented 2 weeks ago

Thank you, I think I found the solution. Another question, please.

I have a radial grid and the first element is named as ' a 1' whose center is at depth 2.5 m. I want to add a new block named ' ba 1' whose center is at depth 0 m (it will be used as "surface" (wellhead) block. I tried the following, but it not working.

new_wellhead_name = ' ba 1' dat.grid.add_block(new_wellhead_name)

The error I get is the following: AttributeError: 'str' object has no attribute 'name'

Moreover, after adding this new wellhead, how to create the connection between ' a 1' and ' ba 1'?

Thank you so much!

acroucher commented 2 weeks ago

When you use t2grid.add_block() the argument should be a t2block object, not a string. So you need to create one first, e.g. blk = t2block(name = ' ba 1'), then dat.grid.add_block(blk). You may want to set other block parameters as well when you create it, e.g. volume. See the documentation for more details.

The procedure for adding a connection is similar, first create a t2connection object and then use t2grid.add_connection().