PhreeqcUsers Discussion Forum

Registrations currently disabled due to excessive spam. Please email phreeqcusers at gmail.com to request an account.
Welcome Guest
 

  • Forum Home
  • Login
  • Register

  • PhreeqcUsers Discussion Forum »
  • Processes »
  • Reactive transport modelling »
  • Loop to repeat transport steps to alternate the injection of two solutions
« previous next »
  • Print
Pages: [1]   Go Down

Author Topic: Loop to repeat transport steps to alternate the injection of two solutions  (Read 1451 times)

maria15143

  • Frequent Contributor
  • Posts: 11
Loop to repeat transport steps to alternate the injection of two solutions
« on: 04/01/24 20:39 »
Hi, nice to meet you. I'm trying to create a model that represents the biodegradation of acetate in a rectangular column of 60cm of lenght in which we alternate the injection of two solutions (one contains the nutrients and the other contains acetate). We have defined RATES, KINETICS, the two solutions and TRANSPORT. The solutions are changed every 400s, which is very low time compared to the time needed for biofilm growth. I wanted to find a way to loop the definition of the SOLUTION 0 which is injected (see example 15) so that the code goes back to the needed solution instead of having to define every time there we change the solution. I don't know if I'm explaining myself, but the end of the code is:


-------------------------------------------------------
[...]
PRINT
   -selected_out false

#10: I WANT THE PROGRAM TO RUN AGAIN FROM THIS AFTER IT FINISHES THE CODE
SOLUTION 0
   temp    23
   Ca   1.42389
   Mg   1.26036
   K   0.2147
   S(6)   0.07040
   N(5)   1.48363
   Na   6.05401
   C(4)   2.08562
   Cl   5.16867
   P    0.0147
END

PRINT
   -selected_out true
TRANSPORT #Injection 2
END

PRINT
   -selected_out false
SOLUTION 0 #Acetate solution that will go in
   temp   23   
   Ca   1.42389
   Mg   1.26036
   K   1.70200   
   Na   1.92652
    C(4)   2.08562
   Cl   5.16867
   P    0.01837
   Acetate   4.27
END

PRINT
   -selected_out true
TRANSPORT #Injection 3
   -shifts 4
END

SOLUTION 0
   temp    23
   Ca   1.42389
   Mg   1.26036
   K   0.2147
   S(6)   0.07040
   N(5)   1.48363
   Na   6.05401
   C(4)   2.08562
   Cl   5.16867
   P    0.0147
END
PRINT
   -selected_out true

TRANSPORT #Injection 4
   -shifts 4
END

#go to comment 10


Thank you very much





Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4036
Re: Loop to repeat transport steps to alternate the injection of two solutions
« Reply #1 on: 04/01/24 21:33 »
If you only have to alternate a few times, I would define the two infilling solutions as SOLUTION, say 1000 and 1001. Then you can copy to SOLUTION 0 as needed.

Code: [Select]
SOLUTION 1000
...
END
SOLUTION 1001
...
END
COPY solution 1000 0
END
TRANSPORT
END
COPY solution 1001 0
END
TRANSPORT
END

If you have to alternate many times, it is possible to program a series of calculations as in Example  8 of the manual. It can be difficult to figure out if you are just getting started, so the COPY approach is best unless you really need to do a lot of iterations.
Logged

MichaelZ20

  • Top Contributor
  • Posts: 162
Re: Loop to repeat transport steps to alternate the injection of two solutions
« Reply #2 on: 08/01/24 08:27 »
Hi David,
I tried to modify the example 11 by following your template and using dump (the next flushing is performed by a different solution). Something goes wrong.
Could you please look at my input file?
Is it possible to show the results of both transport simulations at the same graph?
Thank you in advance for your help!
Code: [Select]
TITLE Example 11
SOLUTION 1000  CaCl2
        units            mmol/kgw
        temp             25.0
        pH               7.0     charge
        pe               12.5    O2(g)   -0.68
        Ca               0.6
        Cl               1.2
END

SOLUTION 1001  MgCl2
        units            mmol/kgw
        temp             25.0
        pH               7.0     charge
        pe               12.5    O2(g)   -0.68
        Ca               Mg
        Cl               1.2
END

SOLUTION 1-40  Initial solution for column
        units            mmol/kgw
        temp             25.0
        pH               7.0     charge
        pe               12.5    O2(g)   -0.68
        Na               1.0
        K                0.2
        N(5)             1.2
END

EXCHANGE 1-40
        -equilibrate 1
        X                0.0011
END

COPY SOLUTION 1000 0
END

TRANSPORT
        -cells           40
        -lengths         0.002
        -shifts          100
        -time_step       720.0
        -flow_direction  forward
        -boundary_conditions   flux  flux
        -diffusion_coefficient 0.0
        -dispersivities  0.002
        -correct_disp    true
        -punch_cells     40
        -punch_frequency 1
        -print_cells     40
        -print_frequency 20
-dump myfile.dmp
-dump_frequency 100  # dump_modulus

DUMP
-cells 1-40
-all

USER_GRAPH 1
  -chart_title ""
  -headings Cl Na K Ca
  -axis_titles "Pore volumes" "Millimoles per kilogram water"
  -plot_concentration_vs time
  -start
  10 GRAPH_x (STEP_NO + 0.5) / cell_no
  20 GRAPH_Y TOT("Cl")*1000, TOT("Na")*1000, TOT("K") *1000, TOT("Ca")*1000
  -end
END

USER_GRAPH 1
-detach

COPY SOLUTION 1001 0

INCLUDE$ myfile.dmp

TRANSPORT
        -cells           40
        -lengths         0.002
        -shifts          100
        -time_step       720.0
        -flow_direction  forward
        -boundary_conditions   flux  flux
        -diffusion_coefficient 0.0
        -dispersivities  0.002
        -correct_disp    true
        -punch_cells     40
        -punch_frequency 1
        -print_cells     40
        -print_frequency 20
-dump_restart 100 # Starting shift number for the calculations, if restarting from a dump file. It equals the shift number at which the dump file was created.

USER_GRAPH 2
  -chart_title ""
  -headings Cl Na K Ca
  -axis_titles "Pore volumes" "Millimoles per kilogram water"
  -plot_concentration_vs time
  -start
  10 GRAPH_x (STEP_NO + 0.5) / cell_no
  20 GRAPH_Y TOT("Cl")*1000, TOT("Na")*1000, TOT("K") *1000, TOT("Ca")*1000
  -end
  END
« Last Edit: 08/01/24 08:30 by MichaelZ20 »
Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4036
Re: Loop to repeat transport steps to alternate the injection of two solutions
« Reply #3 on: 08/01/24 15:48 »
At least in your case, there is no need to dump the state of the column; it doesn't change unless you want to redefine something for cells 1-40.

Also, you only need to redefine items in TRANSPORT if they change.

The same USER_GRAPH can be used for both TRANSPORT calculations, although I modified the pore-volume calculation to use TOTAL_TIME, which is a little easier

I think the following is equivalent to the calculation you had in mind.

Code: [Select]
TITLE Example 11
SOLUTION 1000  CaCl2
        units            mmol/kgw
        temp             25.0
        pH               7.0     charge
        pe               12.5    O2(g)   -0.68
        Ca               0.6
        Cl               1.2
END

SOLUTION 1001  MgCl2
        units            mmol/kgw
        temp             25.0
        pH               7.0     charge
        pe               12.5    O2(g)   -0.68
        Mg               0.6
        Cl               1.2
END

SOLUTION 1-40  Initial solution for column
        units            mmol/kgw
        temp             25.0
        pH               7.0     charge
        pe               12.5    O2(g)   -0.68
        Na               1.0
        K                0.2
        N(5)             1.2
END

EXCHANGE 1-40
        -equilibrate 1
        X                0.0011
END

COPY SOLUTION 1000 0
END

TRANSPORT
        -cells           40
        -lengths         0.002
        -shifts          100
        -time_step       720.0
        -flow_direction  forward
        -boundary_conditions   flux  flux
        -diffusion_coefficient 0.0
        -dispersivities  0.002
        -correct_disp    true
        -punch_cells     40
        -punch_frequency 1
        -print_cells     40
        -print_frequency 20
-dump myfile.dmp
-dump_frequency 100  # dump_modulus

USER_GRAPH 1
  -chart_title ""
  -headings time Cl Na K Ca Mg
  -axis_titles "Pore volumes" "Millimoles per kilogram water"
  -plot_concentration_vs time
  -start
  #10 GRAPH_x (STEP_NO + 0.5) / cell_no
  10 GRAPH_X TOTAL_TIME / (720*40)
  20 GRAPH_Y TOT("Cl")*1000, TOT("Na")*1000, TOT("K") *1000, TOT("Ca")*1000, TOT("Mg")*1000
  -end
END

COPY SOLUTION 1001 0
END
TRANSPORT
END
Logged

  • Print
Pages: [1]   Go Up
« previous next »
  • PhreeqcUsers Discussion Forum »
  • Processes »
  • Reactive transport modelling »
  • Loop to repeat transport steps to alternate the injection of two solutions
 

  • SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies
  • XHTML
  • RSS
  • WAP2