Beispiel #1
0
def kinetic_problem_with_h2o_hcl_caco3_mgco3_co2_calcite():
    """
    Build a kinetic problem with 1 kg of H2O, 1mmol of HCl which has calcite
    as a kinetic reaction
    """

    database = Database("supcrt98.xml")

    editor = ChemicalEditor(database)
    editor.addAqueousPhaseWithElementsOf("H2O HCl CaCO3 MgCO3")
    editor.addGaseousPhase(["H2O(g)", "CO2(g)"])
    editor.addMineralPhase("Calcite")

    calcite_reaction = editor.addMineralReaction("Calcite")
    calcite_reaction.setEquation("Calcite = Ca++ + CO3--")
    calcite_reaction.addMechanism("logk = -5.81 mol/(m2*s); Ea = 23.5 kJ/mol")
    calcite_reaction.addMechanism(
        "logk = -0.30 mol/(m2*s); Ea = 14.4 kJ/mol; a[H+] = 1.0")
    calcite_reaction.setSpecificSurfaceArea(10, "cm2/g")

    system = ChemicalSystem(editor)
    reactions = ReactionSystem(editor)

    partition = Partition(system)
    partition.setKineticPhases(["Calcite"])

    problem = EquilibriumProblem(system)
    problem.setPartition(partition)
    problem.add("H2O", 1, "kg")
    problem.add("HCl", 1, "mmol")

    return (problem, reactions, partition)
Beispiel #2
0
def kinetic_problem_with_h2o_nacl_caco3_mgco3_hcl_co2_calcite_magnesite_dolomite_halite(
):
    """
    Build a kinetic problem with 1 kg of H2O, 1 mol of NaCl and 1 mol of CO2
    which has the following kinetic reactions: calcite, Magnesite and Dolomite.
    """
    database = Database("supcrt98.xml")

    editor = ChemicalEditor(database)

    editor.addAqueousPhaseWithElementsOf("H2O NaCl CaCO3 MgCO3 HCl")
    editor.addGaseousPhase(["H2O(g)", "CO2(g)"])
    editor.addMineralPhase("Calcite")
    editor.addMineralPhase("Magnesite")
    editor.addMineralPhase("Dolomite")
    editor.addMineralPhase("Halite")

    calcite_reaction = editor.addMineralReaction("Calcite")
    calcite_reaction.setEquation("Calcite = Ca++ + CO3--")
    calcite_reaction.addMechanism("logk = -5.81 mol/(m2*s); Ea = 23.5 kJ/mol")
    calcite_reaction.addMechanism(
        "logk = -0.30 mol/(m2*s); Ea = 14.4 kJ/mol; a[H+] = 1.0")
    calcite_reaction.setSpecificSurfaceArea(10, "cm2/g")

    magnesite_reaction = editor.addMineralReaction("Magnesite")
    magnesite_reaction.setEquation("Magnesite = Mg++ + CO3--")
    magnesite_reaction.addMechanism(
        "logk = -9.34 mol/(m2*s); Ea = 23.5 kJ/mol")
    magnesite_reaction.addMechanism(
        "logk = -6.38 mol/(m2*s); Ea = 14.4 kJ/mol; a[H+] = 1.0")
    magnesite_reaction.setSpecificSurfaceArea(10, "cm2/g")

    dolomite_reaction = editor.addMineralReaction("Dolomite")
    dolomite_reaction.setEquation("Dolomite = Ca++ + Mg++ + 2*CO3--")
    dolomite_reaction.addMechanism("logk = -7.53 mol/(m2*s); Ea = 52.2 kJ/mol")
    dolomite_reaction.addMechanism(
        "logk = -3.19 mol/(m2*s); Ea = 36.1 kJ/mol; a[H+] = 0.5")
    dolomite_reaction.setSpecificSurfaceArea(10, "cm2/g")

    system = ChemicalSystem(editor)
    reactions = ReactionSystem(editor)

    partition = Partition(system)
    partition.setKineticSpecies(["Calcite", "Magnesite", "Dolomite"])

    problem = EquilibriumProblem(system)
    problem.setPartition(partition)
    problem.add("H2O", 1, "kg")
    problem.add("NaCl", 1, "mol")
    problem.add("CO2", 1, "mol")

    return (problem, reactions, partition)
Beispiel #3
0
def brine_co2_path():
    editor = ChemicalEditor()
    editor.addAqueousPhaseWithElementsOf("H2O NaCl CaCO3 MgCO3")
    editor.addGaseousPhase(["H2O(g)", "CO2(g)"])
    editor.addMineralPhase("Calcite")
    editor.addMineralPhase("Magnesite")
    editor.addMineralPhase("Dolomite")
    editor.addMineralPhase("Halite")

    editor.addMineralReaction("Calcite") \
        .setEquation("Calcite = Ca++ + CO3--") \
        .addMechanism("logk = -5.81 mol/(m2*s); Ea = 23.5 kJ/mol") \
        .addMechanism("logk = -0.30 mol/(m2*s); Ea = 14.4 kJ/mol; a[H+] = 1.0") \
        .setSpecificSurfaceArea(10, "cm2/g")

    editor.addMineralReaction("Magnesite") \
        .setEquation("Magnesite = Mg++ + CO3--") \
        .addMechanism("logk = -9.34 mol/(m2*s); Ea = 23.5 kJ/mol") \
        .addMechanism("logk = -6.38 mol/(m2*s); Ea = 14.4 kJ/mol; a[H+] = 1.0") \
        .setSpecificSurfaceArea(10, "cm2/g")

    editor.addMineralReaction("Dolomite") \
        .setEquation("Dolomite = Ca++ + Mg++ + 2*CO3--") \
        .addMechanism("logk = -7.53 mol/(m2*s); Ea = 52.2 kJ/mol") \
        .addMechanism("logk = -3.19 mol/(m2*s); Ea = 36.1 kJ/mol; a[H+] = 0.5") \
        .setSpecificSurfaceArea(10, "cm2/g")

    system = ChemicalSystem(editor)
    reactions = ReactionSystem(editor)

    partition = Partition(system)
    partition.setKineticSpecies(["Calcite", "Magnesite", "Dolomite"])

    problem = EquilibriumProblem(system)
    problem.setPartition(partition)
    problem.setTemperature(60, "celsius")
    problem.setPressure(100, "bar")
    problem.add("H2O", 1, "kg")
    problem.add("NaCl", 0.5, "mol")
    problem.add("CO2", 1, "mol")

    state = equilibrate(problem)

    state.setSpeciesMass("Calcite", 100, "g")
    state.setSpeciesMass("Dolomite", 50, "g")

    path = KineticPath(reactions)
    path.setPartition(partition)

    return path, state
Beispiel #4
0
def test_add_phases_with_elements_of_right_use():
    """Test the normal use of addAqueousPhaseWithElementsOf, addGaseousPhaseWithElementsOf and addMineralPhaseWithElementsOf."""
    editor1 = ChemicalEditor()
    editor1.addAqueousPhaseWithElementsOf("H2O Ca")
    editor1.addGaseousPhaseWithElementsOf("CO2 H")
    editor1.addMineralPhaseWithElementsOf("CaCO3")

    editor2 = ChemicalEditor()
    editor2.addAqueousPhaseWithElementsOf(["H2O", "Ca"])
    editor2.addGaseousPhaseWithElementsOf(["CO2", "H"])
    editor2.addMineralPhaseWithElementsOf(["CaCO3"])

    system1 = ChemicalSystem(editor1)
    system2 = ChemicalSystem(editor2)

    _check_equivalent_chemical_systems(system1, system2)
Beispiel #5
0
def equilibrium_problem_with_h2o_feoh2_feoh3_nh3_magnetite():
    """
    Build a problem with H2O, Fe(OH)2, Fe(OH)3, NH3 and Magnetite
    """
    database = Database("supcrt98.xml")

    editor = ChemicalEditor(database)
    editor.addAqueousPhaseWithElementsOf("H2O Fe(OH)2 Fe(OH)3 NH3")
    editor.addGaseousPhaseWithElementsOf("NH3")
    editor.addMineralPhase("Magnetite")

    system = ChemicalSystem(editor)

    problem = EquilibriumProblem(system)
    problem.add("H2O", 1, "kg")
    problem.add("Fe(OH)2", 1, "mol")
    problem.add("Fe(OH)3", 2, "mol")
    problem.add("NH3", 1, "mol")

    return (system, problem)
Beispiel #6
0
def equilibrium_inverse_with_h2o_nacl_caco3_co2_calcite_fixed_phase_volume():
    """
    Build a problem with H2O, NaCl, CaCO3, CO2 and Calcite 
    with fixed values of phase volume 
    """
    editor = ChemicalEditor()
    editor.addAqueousPhaseWithElementsOf("H2O NaCl CaCO3")
    editor.addGaseousPhase(["H2O(g)", "CO2(g)"])
    editor.addMineralPhase("Calcite")

    system = ChemicalSystem(editor)

    problem = EquilibriumInverseProblem(system)
    problem.add("H2O", 1, "kg")
    problem.add("NaCl", 0.1, "mol")
    problem.fixPhaseVolume("Gaseous", 0.2, "m3", "CO2")
    problem.fixPhaseVolume("Aqueous", 0.3, "m3", "1 kg H2O; 0.1 mol NaCl")
    problem.fixPhaseVolume("Calcite", 0.5, "m3", "CaCO3")

    return (system, problem)
Beispiel #7
0
def equilibrium_inverse_with_h2o_nacl_caco3_co2_fixed_mass_amount_and_alkalinity():
    """
    Build a problem with H2O, NaCl, CaCO3, CO2 and Calcite
    with fixed values of Species Mass, Amount and alkalinity
    """
    editor = ChemicalEditor()
    editor.addAqueousPhaseWithElementsOf("H2O NaCl CaCO3")
    editor.addGaseousPhase(["H2O(g)", "CO2(g)"])
    editor.addMineralPhase("Calcite")

    system = ChemicalSystem(editor)

    problem = EquilibriumInverseProblem(system)
    problem.add("H2O", 1, "kg")
    problem.add("NaCl", 0.1, "mol")
    problem.fixSpeciesMass("Calcite", 100, "g")
    problem.fixSpeciesAmount("CO2(g)", 1.0, "mol")
    problem.alkalinity(25.0, "meq/L", "Cl")

    return (system, problem)
Beispiel #8
0
def equilibrium_inverse_with_h2o_nacl_caco3_calcilte_and_fixed_mass():
    """
    Build a problem with H2O, NaCL, CaCO3, CO2, Calcite with fixed
    species mass and amount  
    """
    database = Database("supcrt98.xml")

    editor = ChemicalEditor(database)
    editor.addAqueousPhaseWithElementsOf("H2O NaCl CaCO3")
    editor.addGaseousPhase(["H2O(g)", "CO2(g)"])
    editor.addMineralPhase("Calcite")

    system = ChemicalSystem(editor)

    problem = EquilibriumInverseProblem(system)
    problem.add("H2O", 1, "kg")
    problem.add("NaCl", 0.1, "mol")
    problem.fixSpeciesMass("Calcite", 100, "g")
    problem.fixSpeciesAmount("CO2(g)", 1.0, "mol")

    return (system, problem)
Beispiel #9
0
def test_CubicEOS_multiple_roots():
    """
    This problem leads to the following CubicEOS roots
    PR - Z1 = 1.00027728
         Z2 = 0.0001655
         Z3 = -0.0011024
    since bmix = 1.635e-05 -> Z3 is an invalid root 
    and since Z3 < Z2 < Z1 -> Z2 is an invalid root.
    Reaktoro should remove Z3, Z2 and proceed instead of removing only Z3 and
    raising the exception "Logic error: it was expected Z roots of size 3, but
    got: 2".
    """
    database = Database("supcrt98.xml")

    editor = ChemicalEditor(database)
    editor.addAqueousPhaseWithElementsOf("H2O Fe(OH)2 Fe(OH)3 NH3")
    editor.addGaseousPhaseWithElementsOf("NH3")
    editor.addMineralPhase("Magnetite")

    system = ChemicalSystem(editor)

    state = ChemicalState(system)

    solver = EquilibriumSolver(system)

    temperature = 298.15
    pressure = 1e5
    b = [
        3.0,
        122.01687012,
        1.0,
        63.50843506,
        0.0,
    ]

    result = solver.approximate(state, temperature, pressure, b)
    assert result.optimum.succeeded

    # check that it doesn't raise an exception
    state.properties()
Beispiel #10
0
def equilibrium_problem_with_h2o_co2_nacl_halite_60C_300bar():
    """
    Build a problem with 1 kg of H2O, 100 g of CO2 and 0.1 mol of NaCl 
    at 60 °C and 300 bar 
    """
    database = Database("supcrt98.xml")

    editor = ChemicalEditor(database)
    editor.addAqueousPhaseWithElementsOf("H2O NaCl CO2")
    editor.addGaseousPhase(["H2O(g)", "CO2(g)"])
    editor.addMineralPhase("Halite")

    system = ChemicalSystem(editor)

    problem = EquilibriumProblem(system)
    problem.add("H2O", 1, "kg")
    problem.add("CO2", 100, "g")
    problem.add("NaCl", 0.1, "mol")
    problem.setTemperature(60, "celsius")
    problem.setPressure(300, "bar")

    return (system, problem)