Пример #1
0
"""Water content for a two-phase, liquid+water vapor evaluator."""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"),
        ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"),
        ("saturation_gas", "sg"),
        ("molar_density_gas", "ng"),
        ("mol_frac_gas", "omega"),
        ("cell_volume", "cv")
        ]
params = []

import sympy
phi, sl, nl, sg, ng, omega, cv = sympy.var("phi,sl,nl,sg,ng,omega,cv")
expression = phi*(sl*nl + sg*ng*omega)*cv;

generate_evaluator("liquid_gas_water_content", "Flow",
                   "liquid+gas water content", "water_content",
                   deps, params, expression=expression, doc=__doc__)
Пример #2
0
a given aspect' as a function of latitude, slope, aspect, and Julian
day of the year, and time of day.

Note that some careful checking and experimentation has found that, in
general, the daily average incident radiation times the 12-noon aspect
modifier correlates reasonably well with the daily average of the
product of the hourly incident radiation and the hourly aspect
modifier.  It is notably better than the daily average radiation times
the daily average aspect modifier.

"""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("slope", "slope"),
        ("aspect", "aspect"),
        ("incoming_shortwave_radiation", "qSWin"),
        ]
params = [("daily_avg", "bool", "estimate factor for a daily averaged radiation"),
          ("lat", "double", "domain-averaged latitude [degrees]"),
          ("doy0", "int", "day of year at time 0 [julian days]")]

generate_evaluator("incident_shortwave_radiation", "SurfaceBalance",
                   "incident shortwave radiation", "incident_shortwave_radiation",
                   deps, params, doc=__doc__)
                   


Пример #3
0
import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
import evaluator_generator

#
deps = [("micropore_pressure", "pm"), ("pressure", "pM"),
        ("relative_permeability", "krM"),
        ("micropore_relative_permeability", "krm"),
        ("micropore_absolute_permeability", "K")]
params = [("gamma", "double", "gamma [-]"), ("delta", "double", "delta [m]")]

evaluator_generator.generate_evaluator("micropore_macropore_flux",
                                       "SurfaceBalance",
                                       "micropore-macropore flux",
                                       "micropore_macropore_flux", deps,
                                       params)
Пример #4
0
"""Rooting depth function.

Sets the root fraction as a function of depth,

F_root =  ( a*exp(-az) + b*exp(-bz) ) / 2

This function is such that the integral over depth = [0,inf) is 1, but
an artificial cutoff is generated.

"""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("depth", "z"),]
params = [("a", "double", "alpha", 7),
          ("b", "double", "beta", 1.75),
          ("z_max", "double", "max rooting depth [m]", 2.0)]

import sympy
z = sympy.var("z")
a_, b_, z_max_ = sympy.var("a_,b_,z_max_")
expression = sympy.Piecewise((0.5 * (a_ * sympy.exp(-a_*z) + b_ * sympy.exp(-b_*z)), z <= z_max_), (0., True))

generate_evaluator("rooting_depth_fraction", "Flow",
                   "rooting depth fraction", "rooting_depth_fraction",
                   deps, params, expression=expression, doc=__doc__)
Пример #5
0
"""Energy for a two-phase, liquid+water vapor evaluator."""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"), ("base_porosity", "phi0"),
        ("saturation_liquid", "sl"), ("molar_density_liquid", "nl"),
        ("internal_energy_liquid", "ul"), ("saturation_gas", "sg"),
        ("molar_density_gas", "ng"), ("internal_energy_gas", "ug"),
        ("density_rock", "rho_r"), ("internal_energy_rock", "ur"),
        ("cell_volume", "cv")]
params = []

import sympy
phi, phi0, sl, nl, ul, sg, ng, ug, rho_r, ur, cv = sympy.var(
    "phi, phi0, sl, nl, ul, sg, ng, ug, rho_r, ur, cv")
expression = (phi * (sl * nl * ul + sg * ng * ug) +
              (1 - phi0) * rho_r * ur) * cv

generate_evaluator("liquid_gas_energy",
                   "Energy",
                   "liquid+gas energy",
                   "energy",
                   deps,
                   params,
                   expression=expression,
                   doc=__doc__)
Пример #6
0
"""Downregulates evaporation from a potential.
"""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("saturation_gas", "sg"),
        ("porosity", "poro"),
        ("potential_evaporation", "pot_evap")]
params = [
    ("dess_dz", "double", "dessicated zone thickness [m]", 0.1),
    ("Clapp_Horn_b", "double", "Clapp and Hornberger b of surface soil [-]", 1.0),]

generate_evaluator("evaporation_downregulation", "SurfaceBalance",
                   "evaporation downregulation via soil resistance", "evaporation",
                   deps, params, doc=__doc__)
Пример #7
0
an artificial cutoff is generated.

"""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [
    ("depth", "z"),
]
params = [("a", "double", "alpha", 7), ("b", "double", "beta", 1.75),
          ("z_max", "double", "max rooting depth [m]", 2.0)]

import sympy
z = sympy.var("z")
a_, b_, z_max_ = sympy.var("a_,b_,z_max_")
expression = sympy.Piecewise(
    (0.5 * (a_ * sympy.exp(-a_ * z) + b_ * sympy.exp(-b_ * z)), z <= z_max_),
    (0., True))

generate_evaluator("rooting_depth_fraction",
                   "Flow",
                   "rooting depth fraction",
                   "rooting_depth_fraction",
                   deps,
                   params,
                   expression=expression,
                   doc=__doc__)
Пример #8
0
"""Richards water content with no vapor."""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"), ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"), ("cell_volume", "cv")]
params = []

import sympy
phi, sl, nl, cv = sympy.var("phi,sl,nl,cv")
expression = phi * sl * nl * cv

generate_evaluator("richards_water_content",
                   "Flow",
                   "richards water content",
                   "water_content",
                   deps,
                   params,
                   expression=expression,
                   doc=__doc__)
Пример #9
0
# phi, sl, nl, beta_ = sympy.var("phi,sl,nl,beta_")
# expression2 = phi*sl*nl*beta_

# generate_evaluator("interfrost_dtheta_dpressure", "Flow",
#                    "interfrost dtheta_dpressure", "DThetaDp_coef",
#                    deps2, params, expression=expression2, doc=__doc__)

deps3 = [("porosity", "phi"),
         ("saturation_liquid", "sl"),
         ("molar_density_liquid", "nl"),
         ("saturation_ice", "si"),
         ("molar_density_ice", "ni"),
         ("density_rock", "rhos"),
         ("temperature", "T"),
         ]
params3 = [("W", "double", "W [K]")]

phi,sl,nl,si,ni,rhos,T,W_ = sympy.var("phi,sl,nl,si,ni,rhos,T,W_")

from sympy import Piecewise, exp

expression_part = (1.-.05)*exp(-((T-273.15)/W_)**2) + .05

expression3 = 1.e-6 * (phi * (sl*nl*75.3399846 + si*ni*37.111518) + (1-phi)*rhos*835 + phi * ni * 6017.1102 * Piecewise( (0., T >= 273.15), (expression_part.diff(T), True)))

generate_evaluator("interfrost_denergy_dtemperature", "Flow",
                   "interfrost denergy_dtemperature", "DEnergyDT_coef",
                   deps3, params3, expression=expression3, doc=__doc__)
          
Пример #10
0
"""Energy for a two-phase, liquid+water vapor evaluator."""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"),
        ("base_porosity", "phi0"),
        ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"),
        ("internal_energy_liquid", "ul"),
        ("saturation_gas", "sg"),
        ("molar_density_gas", "ng"),
        ("internal_energy_gas", "ug"),
        ("density_rock", "rho_r"),
        ("internal_energy_rock", "ur"),
        ("cell_volume", "cv")
        ]
params = []

import sympy
phi, phi0, sl, nl, ul, sg, ng, ug, rho_r, ur, cv = sympy.var("phi, phi0, sl, nl, ul, sg, ng, ug, rho_r, ur, cv")
expression = (phi*(sl*nl*ul + sg*ng*ug) + (1-phi0)*rho_r*ur) * cv;

generate_evaluator("liquid_gas_energy", "Energy",
                   "liquid+gas energy", "energy",
                   deps, params, expression=expression, doc=__doc__)
Пример #11
0
"""Distributes transpiration based upon a rooting depth and a wilting-point water-potential factor.
"""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("pressure", "p"),
        ("rooting_depth_fraction", "f_root"),
        ("transpiration", "trans_total")]
params = [("wp_min", "double", "wilting point [Pa]", -2.0e6),]

generate_evaluator("transpiration_distribution", "Flow",
                   "transpiration distribution via rooting depth", "transpiration",
                   deps, params, doc=__doc__)
Пример #12
0
"""Richards energy: the standard form as a function of liquid saturation and specific internal energy."""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"),
        ("base_porosity", "phi0"),
        ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"),
        ("internal_energy_liquid", "ul"),
        ("density_rock", "rho_r"),
        ("internal_energy_rock", "ur"),
        ("cell_volume", "cv")
        ]
params = []

import sympy
phi, phi0, sl, nl, ul, rho_r, ur, cv = sympy.var("phi, phi0, sl, nl, ul, rho_r, ur, cv")
expression = (phi*(sl*nl*ul) + (1-phi0)*rho_r*ur) * cv;

generate_evaluator("richards_energy", "Energy",
                   "richards energy", "energy",
                   deps, params, expression=expression, doc=__doc__)
Пример #13
0
"""Water content for a three-phase, gas+liquid+ice evaluator."""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"),
        ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"),
        ("saturation_ice", "si"),
        ("molar_density_ice", "ni"),
        ("saturation_gas", "sg"),
        ("molar_density_gas", "ng"),
        ("mol_frac_gas", "omega"),
        ("cell_volume", "cv")
        ]
params = []

import sympy
phi, sl, nl, si, ni, sg, ng, omega, cv = sympy.var("phi,sl,nl,si,ni,sg,ng,omega,cv")
expression = phi*(sl*nl + si*ni + sg*ng*omega)*cv;

generate_evaluator("three_phase_water_content", "Flow",
                   "three phase water content", "water_content",
                   deps, params, expression=expression, doc=__doc__)
Пример #14
0
"""Energy evaulator for ice+liquid surface water."""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("ponded_depth", "h"),
        ("unfrozen_fraction", "eta"),
        ("molar_density_liquid", "nl"),
        ("internal_energy_liquid", "ul"),
        ("molar_density_ice", "ni"),
        ("internal_energy_ice", "ui"),
        ("cell_volume", "cv")
        ]
params = []

import sympy
h, eta, nl, ul, ni, ui, cv = sympy.var("h, eta, nl, ul, ni, ui, cv")
expression = h * ( eta*nl*ul + (1-eta)*ni*ui ) * cv;

generate_evaluator("surface_ice_energy", "Energy",
                   "surface ice energy", "energy",
                   deps, params, expression=expression, doc=__doc__)
Пример #15
0
"""Distributes transpiration based upon a rooting depth and a wilting-point water-potential factor.
"""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("pressure", "p"), ("rooting_depth_fraction", "f_root"),
        ("transpiration", "trans_total")]
params = [
    ("wp_min", "double", "wilting point [Pa]", -2.0e6),
]

generate_evaluator("transpiration_distribution",
                   "Flow",
                   "transpiration distribution via rooting depth",
                   "transpiration",
                   deps,
                   params,
                   doc=__doc__)
Пример #16
0
"""Richards water content evaluator: the standard form as a function of liquid saturation."""

import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"),
        ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"),
        ("cell_volume", "cv")
        ]
params = []

import sympy
phi, sl, nl, cv = sympy.var("phi,sl,nl,cv")
expression = phi*sl*nl*cv;

generate_evaluator("richards_water_content", "Flow",
                   "richards water content", "water_content",
                   deps, params, expression=expression, doc=__doc__)
Пример #17
0
"""Energy for a three-phase, gas+liquid+ice evaluator."""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"), ("base_porosity", "phi0"),
        ("saturation_liquid", "sl"), ("molar_density_liquid", "nl"),
        ("internal_energy_liquid", "ul"), ("saturation_ice", "si"),
        ("molar_density_ice", "ni"), ("internal_energy_ice", "ui"),
        ("saturation_gas", "sg"), ("molar_density_gas", "ng"),
        ("internal_energy_gas", "ug"), ("density_rock", "rho_r"),
        ("internal_energy_rock", "ur"), ("cell_volume", "cv")]
params = []

import sympy
phi, phi0, sl, nl, ul, si, ni, ui, sg, ng, ug, rho_r, ur, cv = sympy.var(
    "phi, phi0, sl, nl, ul, si, ni, ui, sg, ng, ug, rho_r, ur, cv")
expression = (phi * (sl * nl * ul + si * ni * ui + sg * ng * ug) +
              (1 - phi0) * rho_r * ur) * cv

generate_evaluator("three_phase_energy",
                   "Energy",
                   "three phase energy",
                   "energy",
                   deps,
                   params,
                   expression=expression,
                   doc=__doc__)
Пример #18
0
"""Water content for a two-phase, liquid+ice evaluator."""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"), ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"), ("saturation_ice", "si"),
        ("molar_density_ice", "ni"), ("cell_volume", "cv")]
params = []

import sympy
phi, sl, nl, si, ni, cv = sympy.var("phi,sl,nl,si,ni,cv")
expression = phi * (sl * nl + si * ni) * cv

generate_evaluator("liquid_ice_water_content",
                   "Flow",
                   "liquid+ice water content",
                   "water_content",
                   deps,
                   params,
                   expression=expression,
                   doc=__doc__)
Пример #19
0
import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
import evaluator_generator

# latent heat
deps = [("litter_water_content", "wc"),
        ("surface_molar_density_liquid", "rho"),
        ("litter_thickness", "L")]
params = [("wc_sat", "double", "saturated litter water content [-]"),
          ("tau", "double", "drying time [s]")]

evaluator_generator.generate_evaluator("evaporative_flux_relaxation", "SurfaceBalance", "evaporative flux relaxation",
                                       "evaporative_flux", deps, params)


# latent heat
deps = [("evaporative_flux", "qe")]
params = [("Le", "double", "latent heat of vaporization [MJ/mol]", .0449994810744)]

evaluator_generator.generate_evaluator("latent_heat", "SurfaceBalance", "latent heat from evaporative flux",
                                       "latent_heat", deps, params)


Пример #20
0
import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
import evaluator_generator

deps = [("temperature", "temp"), ("pressure", "pres")]
params = [("cv", "double", "heat capacity"),
          ("T0", "double", "reference temperature [K]")]

import sympy
cv, T0 = sympy.var("cv_,T0_")
p, T = sympy.var("pres,temp")
expression = cv * (temp - T0)

evaluator_generator.generate_evaluator("eos_ideal_gas",
                                       "General",
                                       "ideal gas equation of state",
                                       "density",
                                       deps,
                                       params,
                                       expression=expression)
Пример #21
0
import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
import evaluator_generator

deps = [("temperature", "temp"), ("pressure", "pres")]
params = [("cv", "double", "heat capacity"),
          ("T0", "double", "reference temperature [K]")]

import sympy
cv, T0 = sympy.var("cv_,T0_")
p, T = sympy.var("pres,temp")
expression = cv * (temp-T0)


evaluator_generator.generate_evaluator("eos_ideal_gas", "General", "ideal gas equation of state",
                                       "density", deps, params, expression=expression)
Пример #22
0
"""Water content for a three-phase, gas+liquid+ice evaluator."""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [("porosity", "phi"), ("saturation_liquid", "sl"),
        ("molar_density_liquid", "nl"), ("saturation_ice", "si"),
        ("molar_density_ice", "ni"), ("saturation_gas", "sg"),
        ("molar_density_gas", "ng"), ("mol_frac_gas", "omega"),
        ("cell_volume", "cv")]
params = []

import sympy
phi, sl, nl, si, ni, sg, ng, omega, cv = sympy.var(
    "phi,sl,nl,si,ni,sg,ng,omega,cv")
expression = phi * (sl * nl + si * ni + sg * ng * omega) * cv

generate_evaluator("three_phase_water_content",
                   "Flow",
                   "three phase water content",
                   "water_content",
                   deps,
                   params,
                   expression=expression,
                   doc=__doc__)
import sys, os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
import evaluator_generator

# 
deps = [("micropore_pressure", "pm"),
        ("pressure", "pM"),
        ("relative_permeability", "krM"),
        ("micropore_relative_permeability", "krm"),
        ("micropore_absolute_permeability", "K")]
params = [("gamma", "double", "gamma [-]"),
          ("delta", "double", "delta [m]")]

evaluator_generator.generate_evaluator("micropore_macropore_flux", "SurfaceBalance", "micropore-macropore flux",
                                       "micropore_macropore_flux", deps, params)



Пример #24
0
"""Interception factor: fraction of incoming precip that is intercepted."""

import sys, os
sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
import evaluator_generator

# latent heat
deps = [
    ("surface-area_index", "ai"),
]
params = [
    ("alpha", "double", "scaling factor [-]", 0.25),
]  # Lawrence 2007

import sympy
ai, alpha_ = sympy.var("ai, alpha")
expression = alpha_ * (1 - sympy.exp(-0.5 * ai))

evaluator_generator.generate_evaluator("interception_fraction",
                                       "SurfaceBalance",
                                       "interception fraction",
                                       "interception_fraction",
                                       deps,
                                       params,
                                       expression=expression)
Пример #25
0
"""

import sys, os

sys.path.append(
    os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator"))
from evaluator_generator import generate_evaluator

deps = [
    ("capillary_pressure_gas_liq", "pc"),
]
params = [("pc_o", "double", "capillary pressure at fully open stomates [Pa]"),
          ("pc_c", "double", "capillary pressure at wilting point [Pa]")]

import sympy

z = sympy.var("pc")
pc_o_, pc_c_ = sympy.var("pc_o_,pc_c_")

# FIXME -- needs a max of 1, min of 0!
expression = (pc_c_ - pc) / (pc_c_ - pc_o_)

generate_evaluator("plant_wilting_factor",
                   "Flow",
                   "plant wilting factor",
                   "plant_wilting_factor",
                   deps,
                   params,
                   expression=expression,
                   doc=__doc__)