yohanesnuwara / pyresim

Reservoir simulator in Python language
Other
81 stars 36 forks source link

Standarize Template File #1

Closed Marior87 closed 4 years ago

Marior87 commented 4 years ago

Hi Yohanes! I was checking some of your code and found something maybe you could check:

As I understand, you are using template.txt as a way to tell users how we are supposed to load data. But with this way I think it is harder to parse it appropriately. Have you tried using a JSON style template? I think it could bring something more maintenable. For example:

template:txt:

RESERVOIR DESCRIPTION

GEOM PROP FLUID REG HOMOG 1PHASE

RESERVOIR INPUT

NX NY NZ DX DY DZ KX KY KZ PORO RHO CPORE MU B CFLUID 50 50 0 100 150 75 150 100 0 0.2 50 0 3.5 1 0


Can become this:

template.json:

{ 'RESERVOIR DESCRIPTION': { 'GEOM' : 'REG', 'PROP' : 'HOMOG', 'FLUID' : '1PHASE' } ..... ..... ..... ..... }

With that you can use json library in Python to parse required information and handle much better the missing one.

Just a thought! And thanks for your dedication!

yohanesnuwara commented 4 years ago

Hi @Marior87, thanks for the valuable suggestion! That's exactly what I also think of. I would like to provide multiple options for input file formats in the near future. Some people are comfortable with TXT, others prefer CSV, others prefer JSON, and others may be a fan of ECLIPSE format. For now, there still isn't any issue regarding parsing from the input TXT data (if you catch any issue, please inform me here), but I absolutely agree with you on the flexibility of JSON, because in the whole operation of reading the input data here in PyReSim (read_input function), the output is dictionary, so JSON is most suitable for this type. I'll cover this next on, and if you are willing to contribute, I would be very glad to work with you on this!

Marior87 commented 4 years ago

To be fair, I am not an expert (I am also a Petroleum Engineer with some programming skills and who loves data science :-) ). My only concern is that in the code, you passed specific line numbers to read data (or at least that is what I understood, maybe I am completely wrong). This could be prone to errors (even adding one line between sections will create issues).

It could also be possible to create some logic to gather information reading line by line a txt file, which could make the code more robust but more complicated. For example:

dict_with_useful_section_names = ['RESERVOIR DESCRIPTION', 'RESERVOIR INPUT',....]

with open('file.txt','r') as f: ----line = f.readLine() ----if line in dict_with_useful_section_names: --------do_something_according_to_section_name

It is just a quick idea, not sure if it is correct nor useful...

Sure would like to help!

yohanesnuwara commented 4 years ago

@Marior87 Thanks for the suggestions. I have opened space for contribution, on translating reservoir data to JSON or ECLIPSE. Feel free to collab, push commits, and make it better! Your input is highly appreciated :)