Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Yuvasriram
    @Yuvasriram
    Thanks a lot @allanleal It's working as expected.
    Omar-Zuair
    @Omar-Zuair
    Hi @allanleal , I wanted to ask if I can access the Pitzer parameters on Reaktoro to add ones for new materials or modify them. I want to model CO2 solubility using an aqueous amine solvent and would like to correlate the pitzer parameters using experimental data.
    Allan Leal
    @allanleal
    Hi Omar. ATM the parameters for the Pitzer model are embedded in the implementation (which needs to be decoupled). This is a planned important work, but I don't have an estimate for when this will be implemented. Can you program in C++?
    3 replies
    bgvinayk
    @bgvinayk
    image.png
    Hi Allan. I have installed reaktoro from environment.yml file. But getting an error in above line. Any suggestions?
    image.png
    image.png
    Svetlana Kyas
    @mtsveta
    Hi @bgvinayk! This is Svetlana, postdoc from Allan's team. He is on vocation at the moment, so I will try to help you.
    From the environment.yml file I see that you are installing 1.2.2 version of reaktoro. At the same time, you are calling db = PhreeqcDatabase("minteq.v4.dat") which is a new functionality from the reaktoro v.2. May I ask if you intend to use the reaktoro v1 or v2?
    If it is v2, you should remove the version of the reaktoro python package in the yml-file.
    Svetlana Kyas
    @mtsveta
    After activating your conda environment, and executing conda list, you should see reaktoro 2.0.0rc22 py39hfc627dd_0 conda-forge if you intend to use the most recent version of reaktoro v2.
    bgvinayk
    @bgvinayk

    Hi @mtsveta Appreciate you quick response. I need to use following code. Which version is recommended?
    db = PhreeqcDatabase("minteq.v4.dat")
    solution = AqueousPhase(speciate("H O Ca Mg Na K C P S Cl N"))
    solution.setActivityModel(ActivityModelDebyeHuckelPHREEQC())
    system = ChemicalSystem(db, solution)
    specs = EquilibriumSpecs(system)
    specs.temperature()
    specs.pressure()
    specs.pH()
    solver = EquilibriumSolver(specs)
    state = ChemicalState(system)

    I have listed reaktoro 2.0.0rc22 version in dependencies now. I am getting some errors like:
    PhreeqcDatabase is not defined
    speciate is not defined
    EquilibriumSpecs is not defined

    I had to use Phreeqc("minteq.v4.dat") instead of PhreeqcDatabase and it worked.
    Also tried removing the reaktoro version and got same result
    Svetlana Kyas
    @mtsveta

    Hi @bgvinayk.

    I need to use following code. Which version is recommended?

    This looks like Reaktoro v2. The snippet of code you shared above runs for me on the 2.0.0rc22 version. Phreeqc("minteq.v4.dat") is the functionality of the version 1.2. I think, you have to make sure that you activate the environment with Reaktoro v2.

    Could you include this lines of code in the try.py script so that I understand better what is going on?

    import sys
    print(sys.path)

    In the command line, it would be python -c 'import sys; print(sys.path)'

    Svetlana Kyas
    @mtsveta

    Also tried removing the reaktoro version and got same result

    I would also try to remove old environment and create the new one from the scratch. Maybe this would help.

    Enrique Garcia Franco
    @EnriqueGarciaFranco

    Hello to all:

    I hope you had a good summer

    I tried creating a new environment

    But since then I get the same errors as @bgvinayk

    It seems like it weren't importing libraries from Reaktoro

    It does

    import reaktoro as rkt

    and then import all

    But it won't be recognized later on the code

    I tried changing the environment and activating it

    Thank you!

    Allan Leal
    @allanleal
    Hi Enrique. I'm checking what is going on. Some dependencies were updated today/recently, and something may be happening related to this.
    Web capture_8-9-2022_205511_colab.research.google.com.jpeg
    As you see above, just used Google Colab to install reaktoro and then run the script in the screenshot. It worked without any issues (the results on the right-hand side). Could you please double check? This is the script I executed:
    from reaktoro import *
    
    db = PhreeqcDatabase("phreeqc.dat")
    
    solution = AqueousPhase(speciate("H O C Na Cl"))
    solution.setActivityModel(chain(
        ActivityModelHKF(),
        ActivityModelDrummond("CO2")
    ))
    
    gases = GaseousPhase("CO2(g)")
    gases.setActivityModel(ActivityModelPengRobinson())
    
    system = ChemicalSystem(db, solution, gases)
    
    T = 25.0 # temperature in celsius
    P = 1.0  # pressure in bar
    
    state = ChemicalState(system)
    state.temperature(T, "celsius")
    state.pressure(P, "bar")
    state.set("H2O"   , 1.0 , "kg")
    state.set("CO2(g)", 10.0, "mol")
    state.set("Na+"   , 4.00, "mol")
    state.set("Cl-"   , 4.00, "mol")
    
    solver = EquilibriumSolver(system)
    solver.solve(state)
    
    props = ChemicalProps(state)
    props.output("props.txt")
    
    aprops = AqueousProps(state)
    aprops.output("aprops.txt")
    
    print("Success! Check outputted files `props.txt` and `aprops.txt`.")
    Allan Leal
    @allanleal
    Also tried in Windows, and all is working fine. Curious to know what you may be doing differently.
    Enrique Garcia Franco
    @EnriqueGarciaFranco

    OK, after chatting one-on-one with Allan it might be the case that I am not working on the right conda environment

    I also had to create a new environment and seems like Reaktoro isn't updated in whichever environment that has been loaded by default on Jupyter Notebook

    I am learning how to change the environment in whichever Python app that I use

    Trying with

    1. Microsoft Visual Studio Code (Community)

    2. Anaconda Jupyter Notebook

    3. Anaconda Spyder

    Allan Leal
    @allanleal
    Thanks, Enrique, for sharing. I highly recommend Visual Studio Code (it's what I use for C++ programming, and Jupyter Notebooks)
    Enrique Garcia Franco
    @EnriqueGarciaFranco

    Yes, thank you. I have been doing my best. Seems that I will need to invest a couple of days into getting all done with it

    I have been able to fix it with Anaconda

    The issue was indeed with the environment

    I fixed it by launching Spyder from Anaconda Navigator after choosing my environment in the very same GUI

    So, my advice for @bgvinayk would be to choose the right environment, in Anaconda distribution or Visual Studio Code

    I find Anaconda easier for me. Visual Code Studio has a more abstract GUI

    1 reply
    bgvinayk
    @bgvinayk
    image.png
    Hi @allanleal I am using above attached code to get tricalcium phosphate saturation index with variation in temperature. I just noticed that its saturation index is decreasing with increase in temperature. But theoretically it is expected to increase with increase in temperature.
    bgvinayk
    @bgvinayk
    image.png
    My guess is it is because delta_H value is positive in the database
    George Dan Miron
    @gdmiron
    @bgvinayk you are right this is because of positive reaction enthalpy which leads to products being more favoured with increasing T. You have to look in the literature for the enthalpy of this reaction or for the enthalpy of formation for this solid. Maybe the value in the database is outdated.
    Enrique Garcia Franco
    @EnriqueGarciaFranco

    Hi

    Calcium salts are strange when heating, this is true

    Calcium hardness tends to precipitate on the walls of dishwashers as a reaction of the temperature increase

    I would analyze the combined effects of enthalpy and entropy

    They key is to see the trend of DG with the increasing temperature for an intuitive set up

    3Ca+2 + 2PO43- -> Ca3(PO4)2 (prec)

    k = exp(-DG/(RT))

    DG = DH - TDS

    If DG is increasing, then k is decreasing with T

    If DG is decreasing, then k is increasing with T

    Allan Leal
    @allanleal
    Interesting. Perhaps, @bgvinayk , you should try one of ThermoFun databases. ThermoFun is fully integrated in Reaktoro. Dan Miron ( @gdmiron ) is the author/main developer. Dan, is there any database in ThermoFun that has this salt?
    George Dan Miron
    @gdmiron
    @bgvinayk I think they have the wrong enthalpy sign there. You can try using mines19-thermofun.json ThermoFun database, you will find this phase there (as whitlockite). This database should have a better T dependence for solids, based on the compilation of Robie and Hemingway. Otherwhise I provide you with a revised data for this phase from PSI tdb2020.
    Tuite
    Ca3(PO4)2 = 3Ca+2 + 2PO4-3
    -analytical_expression 1922.963 0 -83280.97 -675.9268474 0 0 0
    -log_K -28.8997
    for this delta_h -81.2 , in this case phreeqc uses the analytical expression so you don't need delta_h explicitly, but you can see it has a negative sign
    bgvinayk
    @bgvinayk
    @gdmiron Thanks. I will try it out.
    Heewon Jung
    @HeewonJung_CNU_twitter
    Hi all,
    I have recently encountered the paper Kyas et al. (2022) and interested in exploring the ODML capability of reaktoro. The paper says that the ODML has been implemented in reaktoro but I am not sure if this capability has been released or is still in the development phase. What should I do, let's say, if I want to test the accuracy of the ODML approach compared to the GEM method in reaktoro? The C++ API reference includes SmartEqulibriumOptions but it doesn't seem to be accessible from python. Any help would be greatly appreciated.
    Thanks
    Enrique Garcia Franco
    @EnriqueGarciaFranco
    Hello Heewon, I have a silly question to kick-start the discussion. What does ODML stand for? Thanks and looking forward to debating!
    Ok, I read it now 🤜🤛
    On-demand-machine-learning
    Allan Leal
    @allanleal

    Hi @HeewonJung_CNU_twitter , the ODML algorithm (as well as chemical kinetics solver) has been recently (late September) implemented for Reaktoro v2, but it is currently available only through my personal GitHub repo in the kinetics branch:

    https://github.com/allanleal/reaktoro/tree/kinetics

    See these classes:

    SmartEquilibriumSolver
    SmartKineticsSolver

    I need to merge that kinetics branch above into main and then produce conda packages for it. However, I'm currently very busy with another project that ends on Nov 15th, so this work will only happen after that.

    taj004
    @taj004
    Hi @allanleal, I hope you are doing well. I was wondering how to write chemical reactions in the canonical form in Reaktoro. For instance, how can the following reactions, in the canonical form,
    HCO_3^− <-> H+ + CO_3 ^2−
    HSO_4^− <-> H+ + SO_4^2−
    OH^− <-> H2O − H^+
    CaCO3 <-> Ca^2+ + CO_3 ^2−
    CaSO4 <-> Ca^2+ + SO_4^2−
    be written in Reaktoro.
    Allan Leal
    @allanleal
    Hi @taj004 - what do you mean by writing them in Reaktoro? What is the context (e.g., defining database from scratch, or extending one with new species)?
    HCO3− = H+ + CO3-2
    HSO4− = H+ + SO4-2
    OH− = H2O − H+
    CaCO3 = Ca+2 + CO3-2
    CaSO4 = Ca+2 + SO4-2
    Above is how the species would be written following the usual convention in Reaktoro
    In case you have a non-unit coefficient, then use * as multiplication sign:
    CaMg(CO3)2 = Ca+2 + Mg+2 + 2*CO3-2
    taj004
    @taj004
    Hi agian @allanleal. Slightly reformulated. If I want to find the chemical equilibrium state of the above reactions, e.g. in a reactive transport simulation, what can I do to ensure that Reaktoro models the reactions in the canonical form? (after feeding Reaktoro the total amount for the species)
    Allan Leal
    @allanleal
    Hi @taj004 . You should not have to worry about how the equilibrium calculation is done (e.g., how to properly select reactions, master/basic/primary species to ensure things are in order - nothing of this is needed). Reaktoro does not need a set of reactions to compute an equilibrium state. It solves this problem by minimizing the Gibbs energy of the system. The final result is identical if you had used an algorithm that solves the mass action equations (because these equations can be derived from the GEM equations). Could you please tell me why you need somehow to instruct Reaktoro about these reactions (in canonical form)?
    If you are solving RTM, formulate the transport equations in terms of amounts/concentrations of elements and charge; and not in terms of total concentrations of master/primary species (in case you are reducing the number of transport equations from number of species to number of primary species).