Skip to content

Commit

Permalink
SALINITY support in CO2STOR
Browse files Browse the repository at this point in the history
  • Loading branch information
moyner committed Oct 15, 2024
1 parent 65630e1 commit c70396a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/CO2Properties/generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ function activity_co2_DS2003(T, P, m_io; check = true)
return gamma_co2
end

function convert_salinity_to_mole_fractions(salinity)
mw_h2o = 0.01801528
moles_nacal = 1e3*salinity*1.0
moles_water = 1000.0/mw_h2o
mf_nacl = moles_nacal/(moles_nacal + moles_water)
return mf_nacl
end

function compute_salinity(inp_mole_fractions=Float64[], names=String[])
@assert sum(inp_mole_fractions) < 0.9 "Should be mass fractions without water"
saltSpecies = ("NaCl", "KCl", "CaSO4", "CaCl2", "MgSO4", "MgCl2")
Expand All @@ -342,19 +350,12 @@ function compute_salinity(inp_mole_fractions=Float64[], names=String[])
mole_fractions[ix] = inp_mole_fractions[i]
end

# Mass of salts ??
mass_salts = mole_fractions .* Mw_salt
mass_salt = sum(mass_salts)
h2o_mass = (1.0 - sum(mole_fractions)) * Mw_h2o

# mass_fractions = m_salt./(sum(m_salt) + h2o_mass)
# @info "??" h2o_mass m_salt mass_fractions
# mass_salt = sum(mass_fractions)
# 1000*mass_salt/(1.0 - mass_salt)
w_salt = mass_salt ./ (h2o_mass + mass_salt)
# TODO: Check this part.
# m_salt is molality of species k in solution (mol k / kg solvent)
# % w_k mass fraction of species k in aqueous phase
m_salt = mole_fractions ./ h2o_mass
m_io = (m_salt[1], m_salt[2], m_salt[3] + m_salt[4], m_salt[5] + m_salt[6], sum(m_salt[1:2]) + 2 * (m_salt[4] + m_salt[6]), m_salt[3] + m_salt[5])
return (m_salt, m_io, nu, Mw_salt, Mw_io, w_salt)
Expand Down
11 changes: 11 additions & 0 deletions src/input_simulation/converter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ function convert_co2store_to_co2_brine!(data; verbose = true)
end
delete!(props, "CNAMES")
end
if haskey(data["PROPS"], "SALINITY")
salinity = data["PROPS"]["SALINITY"]
if haskey(rs, "SALTS") && salinity > 0.0
local_warn("Both SALINITY and salts declared as COMPS are present. COMPS will be used.")
else
local_msg("Converting SALINITY to NaCL salt.")
salt_mf = CO2Properties.convert_salinity_to_mole_fractions(salinity)
data["PROPS"]["SALTS"] = ["NaCl"]
data["PROPS"]["SALT_MOLE_FRACTIONS"] = salt_mf
end
end
# ZMFVD (convert)
zmfvd = get(props, "ZMFVD", nothing)
if isnothing(zmfvd)
Expand Down

0 comments on commit c70396a

Please sign in to comment.