Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    specmicp
    @specmicp
    It's great that you are already considering it, thank you as always for your great work :)
    Allan Leal
    @allanleal
    Right, thanks for the suggestion and feedback. I think this may happen naturally (and in a way that will allow not only thermodynamic/chemical data to be store, but also physical ones).
    Robert Collar
    @cardinalgeo

    @allanleal, regarding our conversation in the thread about constraining the H2O(g)-H2O(l) phase boundary in P-T space, I tested a few different constraint and initial condition combos:

    • constrain amount of aqueous phase , start with an amount of gaseous phase
    • constrain amount of aqueous phase, start with an amount of aqueous phase
    • constraint amount of gaseous phase, start with an amount of aqueous phase
    • constrain amount of gaseous phase, start with an amount of gaseous phase

    The first three succeeded, but the last failed with the following error message:

    Screen Shot 2022-02-23 at 9.43.23 AM.png
    And here's the code that produced it:
    import reaktoro as rkt 
    db = rkt.ThermoFunDatabase("slop98")
    
    # initialize object to hold phases
    phases = rkt.Phases(db)
    
    # add species to aq. phase; add aq. phase to system
    aqueous_phase = rkt.AqueousPhase(["H2O@"])        # aq. species
    phases.add(aqueous_phase)
    
    # add species to gas phase; add gas phase to system
    gaseous_phase = rkt.GaseousPhase(["H2O"]) # gases
    phases.add(gaseous_phase)
    
    # create system
    system = rkt.ChemicalSystem(phases)
    
    # set specifications for equilibrium solver
    specs = rkt.EquilibriumSpecs(system)
    
    specs.temperature()   
    specs.phaseAmount("GaseousPhase")
    
    # set constraints and calculate equilibrium state
    solver = rkt.EquilibriumSolver(specs)
    conditions = rkt.EquilibriumConditions(specs)
    
    conditions.temperature(150, "C")
    conditions.phaseAmount("GaseousPhase", 1e-6)
    
    conditions.setLowerBoundPressure(1.0, "bar")
    conditions.setUpperBoundPressure(100.0, "bar")
    
    # initialize state
    state = rkt.ChemicalState(system) 
    state.set("H2O", 1, "kg")
    
    result = solver.solve(state, conditions)
    if result.optima.succeeded is True: 
        print("The equilibrium calculation succeeded!")
    else: 
        print("The equilibrium calculation failed!")
    
    print(state)
    Intuitively, the equilibrium state should not depend on the initial condition in this case, but I guess there's an algorithmic reason for why it did not converge?
    Allan Leal
    @allanleal
    Hi Robert. I'll try to run this later and see what is going on. From the error message, some iteration produced nan for the unknown pressure during the calculation, and this is what caused the failure.
    Robert Collar
    @cardinalgeo
    No problem, thanks! And to interrupt the stream of issues I've raised, here's a simple but wonderful plot of the water liquid-vapor saturation curve produced by reaktoro!
    Screen Shot 2022-02-23 at 10.04.12 AM.png
    Allan Leal
    @allanleal
    Cool, thanks! It will be nice to see these general constraint capabilities in the equilibrium solver to be used for sharp/high-res phase diagram plotting (following the phase boundaries, for example).
    Robert Collar
    @cardinalgeo
    Yes! I think this is a super exciting application that'll make generating phase diagrams under myriad conditions much easier!
    Avi Anthony
    @firestorm-buckman
    @allanleal , we have been obtaining saturation indices for various scales. We were unable to obtain the Saturation Indices for Tri-Calcium Phosphate (TCP). Although we used the following atoms for speciation in the aqeous phase, we could not get the SI for TCP.
    solution = AqueousPhase(speciate("H O Na Cl Ca C Si Mg P S K Zn")). Please let us know how could we obtain it ?
    Allan Leal
    @allanleal
    @firestorm-buckman , what's the database you are using?
    Avi Anthony
    @firestorm-buckman
    @allanleal
    db = PhreeqcDatabase("phreeqc.dat")
    Allan Leal
    @allanleal
    @firestorm-buckman This substance is not in the phreeqc.dat database; that's why. You can find Ca3(PO4)2 in llnl.dat, minteq.v4.dat, and sit.dat.
    Avi Anthony
    @firestorm-buckman
    Thank you @allanleal
    Allan Leal
    @allanleal
    :+1:
    specmicp
    @specmicp

    Hello, what is the correct way of doing this :

    aq_solution = rkt.AqueousPhase(rkt.speciate("Na Cl"), rkt.exclude("ClO4-"))

    i.e., excluding a particular species, oxidation state from the database while leaving everything else ?

    Allan Leal
    @allanleal

    Hello! You'll need to list the species you want as shown below:

    AqueousPhase("H2O H+ OH- Na+ Cl-")  # species names need to be exactly as found in the database

    There is no capability at the moment to remove/exclude species with a certain oxidation state from the definition of a phase.

    specmicp
    @specmicp
    Ok, that's what I thought but wanted to be sure, thank you Allan
    specmicp
    @specmicp

    I'm trying to compile Reaktoro to better understands how it works, (and see if I can do a few pull requests for missing python binfdings (e.g. ElementComposition iterator)), but I run into a strange issue with the tests in ChemicalProps:

    >       state.setTemperature(100.0)#, 'celsius')
    E       TypeError: setTemperature(): incompatible function arguments. The following argument types are supported:
    E           1. (self: reaktoro.reaktoro4py.ChemicalState, arg0: autodiff::detail::Real<1ul, double>) -> None
    E           2. (self: reaktoro.reaktoro4py.ChemicalState, arg0: autodiff::detail::Real<1ul, double>, arg1: str) -> None

    The problem is in the first argument. Where are the python overload for real defined ?

    Allan Leal
    @allanleal
    I face this error always when autodiff and reaktoro are compuled with different compilers (or same compilers, different versions).
    I've not found a solution for this, as I'm afraid it is something happening in pybind11 (since I've tried many workarounds to eliminate this issue)
    Could you please confirm if different compilers (or different versions) were used?
    specmicp
    @specmicp
    oh yes that would make sense
    autodiff was installed with conda, and the main gcc is used
    Allan Leal
    @allanleal
    The really best way is to adopt conda as a deps manager. If you do, this should not happen. Because the same compiler (provided by conda-forge) will be used to compile both Reaktoro and autodiff.

    and the main gcc is used

    Is this gcc from your system, right?

    specmicp
    @specmicp
    conda env create -f environment.yml should have installed gcc as it is listed there
    unless gcc is treated differently than the other packages ?
    Allan Leal
    @allanleal
    Here is my suggestion:
    1. clean the build dir (rm -rf *)
    2. conda activate reaktoro
    3. cmake .. in the build dir
    Let me show you how the cmake config messages appear here if you have the conda env activated
    -- CCache: Found ccache installed.
    -- CCache: Using ccache to potentially speed up the build operation.
    -- The CXX compiler identification is GNU 9.4.0
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /home/allan/miniconda3/envs/reaktoro/bin/x86_64-conda-linux-gnu-c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- CondaAware: Conda environment detected!
    -- CondaAware: Found environment variable CONDA_PREFIX=/home/allan/miniconda3/envs/reaktoro
    -- CondaAware: Setting PYTHON_EXECUTABLE=/home/allan/miniconda3/envs/reaktoro/bin/python
    -- CondaAware: Set CONDA_AWARE_PREFIX=/home/allan/miniconda3/envs/reaktoro
    -- CondaAware: Setting CMAKE_INSTALL_PREFIX=CONDA_AWARE_PREFIX=/home/allan/miniconda3/envs/reaktoro
    -- CondaAware: Appended /home/allan/miniconda3/envs/reaktoro to CMAKE_PREFIX_PATH
    -- CondaAware: Appended /home/allan/miniconda3/envs/reaktoro/include to include directories
    -- CondaAware: Appended /home/allan/miniconda3/envs/reaktoro/lib to link directories
    You can see above that the compiler from the conda environment was used, instead of system's compiler.
    specmicp
    @specmicp
    Yes indeed ! This time the correct compiler got selected
    I guess I must have something out of order the first time
    Sorry about that, it also solved the bug #243 ... I guess default parameters are not the same
    Allan Leal
    @allanleal
    No worries.
    Let me know if you encounter further issues.
    specmicp
    @specmicp
    do you plan to ever go back to the main eigen, or main phreeqc if possible ?
    for coupling with my own software it would be easier no to go through conda (but I recognize it makes everything much easier in all cases)
    Allan Leal
    @allanleal
    You are probably referring to eigen4rtk and phreeqc4rkt packages. The eigen4rtk is a workaround created before Eigen 3.4 version was released. eigen4rtk will eventually not be used, and Eigen (maybe some pinned version) will be used from conda-forge.
    phreeqc4rktincludes some changes in the PHREEQC source code. It will probably continue to exist for a while.
    specmicp
    @specmicp
    ok, thank you for the information
    bgvinayk
    @bgvinayk

    state = ChemicalState(system)
    I'm getting an error in following line which used to work before:
    state.temperature(25.0, "celsius")
    TypeError: temperature(): incompatible function arguments. The following argument types are supported:

    1. (self: reaktoro.reaktoro4py.ChemicalState, arg0: autodiff::detail::Real<1ul, double>) -> None
    2. (self: reaktoro.reaktoro4py.ChemicalState, arg0: autodiff::detail::Real<1ul, double>, arg1: str) -> None
    3. (self: reaktoro.reaktoro4py.ChemicalState) -> autodiff::detail::Real<1ul, double>

    Is there any solution to fix this?

    Allan Leal
    @allanleal
    Hi @bgvinayk , are you using Reaktoro from conda? What is the version?
    There was a new package produced this morning, v2.0rc19, wondering if this is the issue
    Allan Leal
    @allanleal
    There is something indeed going on with the new release.
    Allan Leal
    @allanleal
    You can install the version before:
    conda install reaktoro=2.0.0rc18