Skip to content

Commit

Permalink
clean up tc1
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Nov 23, 2023
1 parent eca7230 commit b99c3df
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions experiments/ClimaCore/tc1_heat-diffusion-with-slab/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ import ClimaCore: Fields, Domains, Topologies, Meshes, DataLayouts, Operators, G
import ClimaTimeSteppers as CTS

using Base: show_supertypes
# using OrdinaryDiffEq: ODEProblem, solve, SSPRK33
import SciMLBase: step!, ODEProblem, init


using Logging: global_logger
using TerminalLoggers: TerminalLogger

Expand Down Expand Up @@ -148,22 +146,17 @@ We also use this model to calculate and accumulate the downward surface fluxes,
"""
function ∑tendencies_atm!(du, u, cache, t)
parameters, T_sfc = cache
T = u.T_atm # u.x = vector of prognostic variables from DifferentialEquations
T = u.T_atm
F_sfc = calculate_flux(T_sfc[1], parent(T)[1], parameters)
## set BCs
# C3 = Geometry.Covariant3Vector
C3 = Geometry.WVector


bcs_bottom = Operators.SetValue(C3(F_sfc)) # F_sfc is converted to a Cartesian vector in direction 3 (vertical)
bcs_top = Operators.SetValue(C3(FT(0)))

ᶠgradᵥ = Operators.GradientC2F()#(top = bcs_top) # Dirichlet BC (center-to-face)
ᶠgradᵥ = Operators.GradientC2F() # Dirichlet BC (center-to-face)
ᶜdivᵥ = Operators.DivergenceF2C(bottom = bcs_bottom, top = bcs_top) # Neumann BC (face-to-center)
# divf2c_water = Operators.DivergenceF2C(
# top = Operators.SetValue(Geometry.WVector.(top_flux_bc)),
# bottom = Operators.SetValue(Geometry.WVector.(bot_flux_bc)),
# )

## tendency calculations
@. du.T_atm = ᶜdivᵥ(parameters.μ * ᶠgradᵥ(T)) # dT/dt
Expand Down Expand Up @@ -214,7 +207,6 @@ stepping = (;
timerange = (0.0, 6.0),
Δt_coupler = 0.1,
odesolver = CTS.ExplicitAlgorithm(CTS.RK4()),
# odesolver = SSPRK33(),
nsteps_atm = 8, # number of timesteps of atm per coupling cycle
nsteps_lnd = 1, # number of timesteps of lnd per coupling cycle
);
Expand Down Expand Up @@ -261,7 +253,7 @@ function coupler_solve!(stepping, ics, parameters)

## STEP ATMOS
## pre_atmos
integ_atm.p[2] .= coupler_get_(coupler_T_lnd) # integ_atm.p is the parameter vector of an ODEProblem from DifferentialEquations
integ_atm.p[2] .= coupler_get_(coupler_T_lnd) # integ_atm.p is the parameter vector of an ODEProblem from SciMLBase
integ_atm.u.atm_F_sfc .= 0.0 # surface flux to be accumulated

## run atmos
Expand Down Expand Up @@ -291,12 +283,13 @@ sol_atm, sol_lnd = integ_atm.sol, integ_lnd.sol;

# ## Postprocessing and Visualization

# Each integrator output (`sol_atm`, `sol_lnd`), contains the DifferentialEquations variable `.u` (the name is hard coded).
# If `ArrayPartition` was used for combining multiple prognostic variables, `u` will include an additional variable `x` (also hard coded)
# Each integrator output (`sol_atm`, `sol_lnd`), contains the SciMLBase variable `.u` (the name is hard coded).
# If multiple prognostic variables were solved for, `u` will contain all of those.
# `parent()` accesses the `Field` values.
# So, for example, the structure of `u` from Model 1 is:
# TODO update comments
# `parent(sol_atm.u[<time-index>].x[<ArrayPartition-index>])[<z-index>,<variable-index>]`
# So, for example, the structure of `u` from the atmosphere model is:
# `parent(sol_atm.u[<time-index>].T_atm)[<z-index>,<variable-index>]`
# and
# `parent(sol_atm.u[<time-index>].atm_F_sfc)[<z-index>,<variable-index>]`

ENV["GKSwstype"] = "nul"
import Plots
Expand Down

0 comments on commit b99c3df

Please sign in to comment.