2

Hello guys . Does anybody know how to simulate the deformation of the soil caused by fluidflow in both TOUGH and FLAC3D? Thanks

84replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Unfortunately, it is not as straightforward as it sounds.

    The "easiest" way that does not require access to TOUGH source code is to make FLAC3D call TOUGH at each time step and import the pressure and temperature from TOUGH into FLAC. For two-way coupling (stress-induced porosity/permeability changes), you should update TOUGH input files before calling TOUGH in FLAC3D.

    Like 1
    • Keurfon Luu can you please be more explicit ?

      Like
    • Floriane Youzan I didn't try the FLACTOUGH (FLAC calling TOUGH) implementation myself. I am suggesting it since the current implementation of TOUGHFLAC (TOUGH calling FLAC) alters TOUGH source code a lot which requires a really good knowledge of the Fortran language. It's even more complicated with TOUGH3 since you should now also consider that arrays are distributed in parallel. However, the TOUGHFLAC implementation is more optimized as it does not require to read and write TOUGH input/output files at each time step.

      Assuming that you have already setup your problem for TOUGH and FLAC3D independently, a quick algorithm would look like as below:

      1. Solve the mechanical state in FLAC3D to a time step Dt,

      2. Calculate stress-induced changes in porosity and/or permeability and update TOUGH input files (MESH and/or INCON) with these new values,

      3. Solve fluid and heat flow in TOUGH to time step Dt,

      4. Import pressure and temperature from SAVE file and update zone pore pressure and temperature in FLAC3D,

      5. Loop back to step 1 until end of simulation.

      FLAC3D has a Python interface which should make this a bit easier to implement compared to using FISH. For instance, you can call an external program in Python as follow:

      import subprocess
      
      subprocess.call(["tough3-eco2n", "INFILE"], shell=True)
      

      To update a zone pore pressure and temperature, I don't remember if there is a zone array for these properties, but you can loop over each zone and update the parameters as follow:

      import itasca as it
      
      for zone in it.zone.list():
          # Interpolate my_pp and my_temp from SAVE file
          zone.set_pp(my_pp)
          zone.set_temp(my_temp)
      

      Reading TOUGH input and output files can be done using toughio. You can install toughio in FLAC3D by running this command in a Windows console:

      cmd /C ""C:/Program Files/Itasca/FLAC3D700/exe64/python36/Scripts/pip.exe"" install toughio --user
      Like 2
    • Keurfon Luu Thank you

      Like
    • Keurfon Luu i am trying to solve the mechanical State in FLAC3D but I am not sure how to do it ! I found an example on FLAC about Groundwater but I am not sure it’s appropriate 

      Like
    • Floriane Youzan Not sure about what you are asking. Assuming that your mesh is generated (with all zone groups assigned if necessary), you simply have to assign constitutive models and properties to your zones, initialize the initial and boundary stress conditions (e.g. roller at the bottom) and then solve the mechanical state to equilibrium.

      Like
    • Keurfon Luu i am fairly new at FLAC3D so when you say solve nechanical state to DT , I don’t really know how to do it. Can you please recommend me an example in the FLAC manual that I can follow ? 
      thanks

      Like
    • Floriane Youzan I've attached a sample FLAC3D script. It shows the main commands to set up your model in FLAC3D.

      Like 1
    • Keurfon Luu thank youuu so much. May God bless you!!!

      Like
    • Floriane Youzan hey, the .dat file you sent me previously, can you please tell me the mesh size you used ? I just wanna compare something.

      Thanks 

      Like
    • Keurfon Luu 

      hey, the .dat file you sent me previously, can you please tell me the mesh size you used ? I just wanna compare something.

      Thanks 

      Like
    • Floriane Youzan It's a 2D model (extruded to 3D):

      xlim = [-350000.0, 350000.0]

      zlim = [-3000.1, 0.0]

      Like 1
    • Keurfon Luu hello, this is the error I get when I try to run the model:

      Model is not current configured for FluidModule, see the MODEL CONFIGURE command.

      While processing line 4 of source C:/Users/LabUser/Documents/Itasca/flac3d700/My Projects/try.dat. Do you know what is it about?

      Like
    • Floriane Youzan Sorry for the late reply.

      I never encountered this issue. Could you send me your script?

      Like
    • Keurfon Luu no problem ! I just used the dat.file you sent me and changed the dimension of the mesh that’s it

      Like
    • Floriane Youzan I am not sure what Line 4 is... is it the command

      model configure fluid

      that does not work?

      Like
    • Keurfon Luu 

      ; Load mesh
      zone import '../mesh.f3grid'

      ; Hydraulic parameters
      zone fluid cmodel assign isotropic
      zone fluid property biot 1.0
      zone fluid property permeability 1.0e-17
      zone fluid property porosity 0.01
      zone gridpoint initialize fluid-modulus 1.0

      ; Mechanical parameters
      zone cmodel assign elastic
      zone property young 5e9
      zone property poisson 0.25

      ; Thermal parameters
      zone thermal cmodel assign isotropic
      zone thermal property conductivity 1.8
      zone thermal property expansion 0.0
      zone thermal property specific-heat 1500

      ; In situ stress
      zone initialize stress-xx 0.0 gradient 0 0 22170.6
      zone initialize stress-yy 0.0 gradient 0 0 22170.6
      zone initialize stress-zz 0.0 gradient 0 0 22170.6
      zone initialize density 2260
      model gravity 0 0 -9.81

      ; In situ pressure and temperature
      zone gridpoint initialize pore-pressure 1.e5 gradient 0 0 -9810.0
      zone gridpoint initialize temperature 10.0 gradient 0 0 -0.025

      ; Mechanical boundaries
      zone gridpoint fix velocity-y
      zone gridpoint fix velocity-z range position-z -3000.1
      zone gridpoint fix velocity-x range position-x -350000.0
      zone gridpoint fix velocity-x range position-x 350000.0

      ; Disable large strain (only FLAC3D v7)
      model large-strain off

      ; Solve model for mechanical equilibrium
      model solve mech ratio 1.0e-8

       

      I used the exact same script but I changed the mesh to mine that's what I did

      Like
    • Floriane Youzan You have to call

      model configure fluid

      before using

      zone fluid something

      Same for thermal, you have to call

      model configure thermal

      before using

      zone thermal something

      See my original script.

      Like
    • Keurfon Luu I thought that is what I did. when you say call you mean write that before I execute the whole code

      Like
    • Floriane Youzan Put it at the beginning of the script. In my original sample script, it starts with

      model configure fluid
      model configure thermal
      
      Like
    • Keurfon Luu hello, I am a little but lost. the mechanical boundaries yoou have in your data file. does it match your mesh? I mean I cant just use it for my mesh right? I have to change it around right

      Like
    • Floriane Youzan Of course.

      In my sample problem, I applied roller boundary conditions everywhere except at the surface. To do so, I prevent lateral grid points from moving horizontally:

      zone gridpoint fix velocity-x range position-x -350000.0
      zone gridpoint fix velocity-x range position-x 350000.0

      And grid points at the bottom of the mesh from moving vertically:

      zone gridpoint fix velocity-z range position-z -3000.1

      Since the sample problem is invariant in y, I fixed the velocity along the Y axis:

      zone gridpoint fix velocity-y
      

      but you shouldn't do that if your mesh is 3D.

      Note that the mesh is 2D (XZ plane) with x in the range [-350000.0, 350000.0] and z in the range [-3000.1, 0.0].

      Like 1
    • Keurfon Luu okay thank you. Like I told you earlier I am trying to use both tough and flac for the simulation. I already solved it in TOUGH to the equilibrium state and I got some data from the SAVE file . However I don’t really know how to use the information I got From Tough in FLAC To solve the problem to equilibrium there too. Do you have an idea?

      Like
    • Floriane Youzan You can read your SAVE file in FLAC3D using toughio.

      save = toughio.read_output("SAVE")

      This returns a namedtuple with a data dictionary that contains the primary variables X1, X2 ... up to X4. The number of primary variables and their meanings depend on the EOS you are using. For instance, for EOS3, X1 corresponds to pressure (or gas pressure if two-phase) and X3 to temperature. You can then update FLAC3D zones' pressures and temperatures using the instruction:

      for i, zone in enumerate(it.zone.list()):
          zone.set_pp(save.data["X1"][i])
          zone.set_temp(save.data["X3"][i])
      
      Like 2
    • Keurfon Luu I am having trouble running the python code because I have to pip install toughio which I did but it is not working. I attached the error

      Like
    • Floriane Youzan You can install toughio for FLAC3D's Python using the command:

      cmd /C ""C:/Program Files/Itasca/FLAC3D700/exe64/python36/Scripts/pip.exe"" install toughio --user
      
      Like
    • Keurfon Luu i get an error when i type that in the command window

      Like
    • Floriane Youzan Call that command in WIndows console, not in FLAC3D (just like you did with pip).

      Like
    • Keurfon Luu they say the system can not find the path specified

      Like
    • Floriane Youzan What's the error?

      Like
    • Keurfon Luu nevermind i did it using another way. the code gives me another error in python . here it is

      Like
    • Floriane Youzan Can you attach the SAVE file you are trying to read?

      Like
    • Keurfon Luu here it is

      Like
    • Floriane Youzan Sorry for the delay. I wanted to fix other bugs and add other features before releasing an update. The latest update of toughio should be able to read your SAVE file now. Please update toughio.

      pip install -U toughio --user

      To update toughio in FLAC3D's Python:

      cmd /C ""C:/Program Files/Itasca/FLAC3D700/exe64/python36/Scripts/pip.exe"" install -U toughio --user
      Like
    • Keurfon Luu hello, thank you for reply, I just tried update toughio but i got an error

      Like
    • Floriane Youzan You forgot the dash before U: -U

      Like
    • Keurfon Luu i think it went through but when i run the code I did not get any error.  I am trying to find the new save file

      Like
    • Floriane Youzan I notice that you installed toughio for Windows' Python installation rather than FLAC3D's built-in Python. This means that you won't be able to import toughio within FLAC3D. To run a coupled TOUGH and FLAC3D simulation (without modifying TOUGH's source code), you HAVE to install toughio for FLAC3D's Python as there is no way to import the module itasca outside of FLAC3D.

      If you get an error when running the command:

      cmd /C ""C:/Program Files/Itasca/FLAC3D700/exe64/python36/Scripts/pip.exe"" install -U toughio --user

      it probably means that FLAC3D is not installed in its default location. What's the exact error returned by Windows console when you run this command?

      Like
    • Keurfon Luu I typed it in the python console that is in FLAC 3D and here is what I got 

      Like
    • Floriane Youzan You have to type it in Windows console, just like you did to install toughio for Windows's Python installation, the only difference is the path to the program pip (Python's package manager).

      Like
    • Floriane Youzan okay I get what you mean now. here is what I got

      Like
    • Floriane Youzan You forgot the option --user at the end of the command.

      cmd /C ""C:/Program Files/Itasca/FLAC3D700/exe64/python36/Scripts/pip.exe"" install -U toughio --user
      Like
    • Keurfon Luu okay I was able to get it done. however when I tried the code in python in FLAC3D they say toughio is not specified. I don't understand

      Like
    • Floriane Youzan Have you restarted FLAC3D?

      Like
    • Keurfon Luu yeah I closed FLAC and opened it back again but still they say that "DLL load failed" the specified module could not be loaded

      Like
    • Floriane Youzan Is it an error related to _lzma?

      Like
    • Keurfon Luu what is _Izma

      Like
    • Floriane Youzan What is the exact error returned by FLAC3D when importing toughio?

      Like
    • Keurfon Luu okay I pip installed it like you recommended and went to the python console in FLAC 3D and typed import toughio and here is what I get

      Like
    • Floriane Youzan Okay, so the error is related to _lzma, as I thought.

      Itasca packages the module lzma in FLAC3D but forgot to include the associated DLL file.

      Download and uncompress the attached ZIP file, and put the file liblzma.dll in the following directory:

      C:\Program Files\Itasca\FLAC3D700\exe64\python36\DLLs

      Restart FLAC3D and retry.

      Like
    • Keurfon Luu I cant put that in that directory I can only put it in the dowloads

      Like
    • Keurfon Luu hello, I was able to extract the Izma file but when I run the code I do not know where the save file is saved. the file I am supposed to extract information from. I did not get any error but I can not find the file

      Like
    • Floriane Youzan I could put the Izma file in the directory and could import tough save file into flac3D by using the command save = toughio.read_output("SAVE") and there is no error but I do not know how to apply the save information into the FLAC 3D file

      Like
    • Floriane Youzan You shouldn't save the data to FLAC3D file, you should import pressure and temperature data arrays from TOUGH in FLAC3D's Python, and then use itasca Python's module built in FLAC3D to import these arrays directly into FLAC3D's zones.

      Assuming that your grid is loaded, the following code will import pressure and temperature calculated by TOUGH to FLAC3D's zones:

      import toughio
      import itasca as it
      
      # Load SAVE file
      save = toughio.read_output("SAVE")
      
      # Loop over FLAC3D's zones and set pressure and temperature
      for i, zone in enumerate(it.zone.list()):
          zone.set_pp(save.data["X1"][i])
          zone.set_temp(save.data["X6"][i])

      You must change the primary variable names depending on the EOS you are using. From your SAVE file, I guessed that you are using EOS7R so pressure corresponds to variable X1 and temperature to variable X6.

      Like 1
    • Keurfon Luu thank you

      Like
    • Floriane Youzan `it went through but they said zonebasedpp must be on

      Like
    • Keurfon Luu it went through but they said ZONEBASEDPP must be on

      Like
    • Floriane Youzan 

      import itasca as it
      
      it.command("zone fluid zone-based-pp on")
      

      If you are using module thermal, also add:

      it.command("zone thermal zone-based-temp on")
      Like 1
    • Keurfon Luu they say model is not configured for FluidModule and then i added model configure fluid at the beginning of the code and it threw an error

      Like
    • Floriane Youzan To put it briefly, you can use 3 different languages in FLAC3D: FLAC3D commands, FISH and Python. Obviously, Python only accepts Python instructions.

      Since

      model configure fluid

      is a FLAC3D command, you cannot use it as-is in a Python script. However, FLAC3D's commands can be used within a Python script using the function "it.command":

      import itasca as it
      
      it.command("model configure fluid")
      
      Like
    • Keurfon Luu another error

      Like
    • Floriane Youzan Can you share your script?

      Like
    • Keurfon Luu nevermind, i think the code is good but we need to update FLAC to get options for "thermal". I have a question though, what would this code solve because I am tryimg to solve the mechanical state to a time step Dt and I dont see time in the whole thing. or is it a step will be done later

      Like
    • Keurfon Luu hey here is my script

      Import toughio

      Import Itasca as it

       it.command(“model configure fluid”)

      it.command(“zone fluid zone-based-pp on”)

       

      save = toughio.read_output("SAVE")

      for i, zone in enumerate(it.zone.list()):

          zone.set_pp(save.data["X1"][i])

      we do not want to deal with any thermal options so I did not use the last line of code you suggested.

      here is the error I got

      Like
    • Floriane Youzan What do you get with?

      it.zone.count()

      and

      save.data["X1"].size

      If your TOUGH MESH file has been created with toughio from your FLAC3D grid, you should have the same number of zones in both.

      Have you imported your FLAC3D grid before running the script?

      Like
    • Keurfon Luu for the zone count I got 18648 and the save size I got 6216

      Like
    • Keurfon Luu I AM pretty sure I did it the right way, please take a look at both my files and let me know. please

      thanks

      Like
    • Floriane Youzan Looks like you imported your grid in FLAC3D thrice (18648 = 3 x 6216).

      Run the FLAC3D command "model new" in FLAC3D's console (or "it.command("model new")" in FLAC3D's iPython's console), then reimport your grid once, and run your script again.

      Note that at this current stage, you have merely imported the steady state results from TOUGH into FLAC3D. You should now loop over FLAC3D time steps (see my early answer).

      Like
    • Keurfon Luu i run the command without importing the grid at first right?

      Like
    • Keurfon Luu I was able to fix the size issue and now both of my MESH have the same size but the thing is when I run the code, nothing happens

      Like
    • Keurfon Luu I was able to fix the size issue and now both of my MESH have the same size but the thing is when I run the code, nothing happens

      Like
    • Floriane Youzan What do you mean? The sample code so far only imports pore pressure calculated by TOUGH in FLAC3D. As I said earlier, you should now loop over time steps and sequentially couples TOUGH and FLAC3D:

      t = 0.0
      dt = 3600.0  # Time step, let's say one hour time step
      tmax = 24.0 * 3600.0  # Simulation time, let's say one day
      while t < tmax:
          # Code to solve fluid flow with TOUGH (e.g., using subprocess to call TOUGH)
          subprocess.call(...)
      
          # Import pore pressure in FLAC3D
          save = toughio.read_output("SAVE")
          for i, zone in enumerate(it.zone.list()):
              zone.set_pp(save.data["X1"][i])
      
          # Solve mechanical state in FLAC3D
          it.command(f"model solve mechanical time {dt}")
      
          # Prepare next time step for TOUGH
          # Modify input file using toughio
          # Rename SAVE file to INCON and modify porosity and/or permeability for each zone
          # (see Rutqvist et al., 2002 for equations)
          ...
      
          # Increment simulation time
          t += dt
      
      Like 1
    • Keurfon Luu hey, thank you for your reply. so far I only ran the first part of the code and I was expecting some kind of response or an output file . I attached a picture of the code. I got a .temp file but it didn't have valuable information

      Like
    • Floriane Youzan No response, no problem. It means that the code ran successfully.

      Now, FLAC3D can use pore pressure from TOUGH to update the mechanical state.

      Like 1
    • Keurfon Luu just time make sure , the time is in second ?

      Like
    • Floriane Youzan Yes, every units in TOUGH are defined following the International System of Units.

      Like
    • Keurfon Luu hello,I am getting an error 

      Like
    • Floriane Youzan I thought it was obvious that the code was only partially completed. The command to put in subprocess to call TOUGH depends on too many factors such as how your computer is set up, which version and EOS of TOUGH you are using, is it compiled using WSL, Cygwin or you just got the executable file from LBL...

      Like
    • Keurfon Luu oh okay thanks 

      Like
    • Keurfon Luu can you please give me some references that can help me write the rest of the code ? 
      thanks 

      Like
  • I guess this reference from Rutqvist gives you a good overview of coupling the two codes.

    Julia

    Like 1
    • JuDi thank you

      Like
  • Floriane Youzan Hello, hope you are doing well! I have found this discussion topic very useful for my research. I am writing on behalf of the GEERG research group from Nazarbayev University.  Currently, we are working on CO2 potential leakage through fault zones using TOUGHFLAC simulation. I am new to this, and for now, I am learning from manuals and other publications on this topic. 

    Could you please provide information/example problems/manuals in this simulation? Thanks

    Like
  • Floriane Youzan Hello, hope you have solved your problem! Now I am confused about the strain induced by the pore-pressure change. Can you give me some advice? When I import the pore-pressure from TOUGH to FLAC, I can find that the effective stress in FLAC have changed, but no corresponding strain generated, so how can I calculate the corresponding strain? Thanks

    Like
Like2 Follow
  • 2 Likes
  • 9 mths agoLast active
  • 84Replies
  • 440Views
  • 6 Following