From 94712461a810e463739cf21b13f3bb99c10a8373 Mon Sep 17 00:00:00 2001 From: sriharshakandala Date: Mon, 25 Nov 2024 10:56:51 -0800 Subject: [PATCH] Initial conditions from file (rough draft, work-in-progress) --- Artifacts.toml | 8 ++ artifacts/artifact_funcs.jl | 13 +++ artifacts/download_artifacts.jl | 1 + config/default_configs/default_config.yml | 2 +- .../gpu_aquaplanet_dyamond_summer.yml | 26 ++++++ src/initial_conditions/initial_conditions.jl | 25 ++++++ src/solver/type_getters.jl | 83 ++++++++++++++++++- src/utils/AtmosArtifacts.jl | 8 ++ 8 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 config/gpu_configs/gpu_aquaplanet_dyamond_summer.yml diff --git a/Artifacts.toml b/Artifacts.toml index 70062a55cab..35199d1be68 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -43,3 +43,11 @@ git-tree-sha1 = "10742e0a2e343d13bb04df379e300a83402d4106" [[era5_cloud.download]] sha256 = "bb51e2f2d315b487e05a8d38944d4ad937ee4a40c43b68541220c5d54425e24a" url = "https://caltech.box.com/shared/static/b6ur4ap4vo04j09vdulem96z9fxqlgyn.gz" + +[DYAMOND_SUMMER_ICS_p98deg] +git-tree-sha1 = "5ef4bb950eceb86430464c8637ede7f075a1449f" +lazy = true + + [[DYAMOND_SUMMER_ICS_p98deg.download]] + sha256 = "da552c32c4e66a053992f3b2c96ebaeb78c1aded1818b4e7c2deea77d521dda1" + url = "https://caltech.box.com/shared/static/ad8d774iwaezctwud1g1lqbp9irbjj38.gz" diff --git a/artifacts/artifact_funcs.jl b/artifacts/artifact_funcs.jl index 491cacacea9..03614aff8de 100644 --- a/artifacts/artifact_funcs.jl +++ b/artifacts/artifact_funcs.jl @@ -61,3 +61,16 @@ function gfdl_ogw_data_path() ) return AW.get_data_folder(gfdl_data) end + +# DYAMOND summer initial conditions +function DYAMOND_SUMMER_ICS_p98deg_dataset_path() + DYAMOND_SUMMER_ICS_p98deg_dataset = AW.ArtifactWrapper( + @__DIR__, + "DYAMOND_SUMMER_ICS_p98deg", + AW.ArtifactFile[AW.ArtifactFile( + url = "https://caltech.box.com/shared/static/1nqueb39ro33b2ps7zm2df9hpbkps6wy.gz", + filename = "DYAMOND_SUMMER_ICS_p98deg.nc", + ),], + ) + return AW.get_data_folder(DYAMOND_SUMMER_ICS_p98deg_dataset) +end diff --git a/artifacts/download_artifacts.jl b/artifacts/download_artifacts.jl index ac7552100e1..2facdc8ce18 100644 --- a/artifacts/download_artifacts.jl +++ b/artifacts/download_artifacts.jl @@ -7,6 +7,7 @@ function trigger_download(lazy_download = true) @info "topo dataset path:`$(topo_res_path())`" @info "MiMA convective gravity wave path:`$(mima_gwf_path())`" @info "GFDL OGWD test data:`$(gfdl_ogw_data_path())`" + @info "DYAMOND summer initial conditions path:`$(DYAMOND_SUMMER_ICS_p98deg_dataset_path())`" return nothing end trigger_download() diff --git a/config/default_configs/default_config.yml b/config/default_configs/default_config.yml index 708cdf0801b..88bc210684b 100644 --- a/config/default_configs/default_config.yml +++ b/config/default_configs/default_config.yml @@ -179,7 +179,7 @@ surface_temperature: help: "Prescribed surface temperature functional form ['ZonallySymmetric' (default), 'ZonallyAsymmetric', 'RCEMIPII']" value: "ZonallySymmetric" initial_condition: - help: "Initial condition [`DryBaroclinicWave`, `MoistBaroclinicWave`, `DecayingProfile`, `IsothermalProfile`, `Bomex`, `DryDensityCurrentProfile`, `AgnesiHProfile`, `ScharProfile`, `RisingThermalBubbleProfile`, `ISDAC`]" + help: "Initial condition [`DryBaroclinicWave`, `MoistBaroclinicWave`, `DecayingProfile`, `IsothermalProfile`, `Bomex`, `DryDensityCurrentProfile`, `AgnesiHProfile`, `ScharProfile`, `RisingThermalBubbleProfile`, `ISDAC`, `DYAMONDSummer`]" value: "DecayingProfile" perturb_initstate: help: "Add a perturbation to the initial condition [`false`, `true` (default)]" diff --git a/config/gpu_configs/gpu_aquaplanet_dyamond_summer.yml b/config/gpu_configs/gpu_aquaplanet_dyamond_summer.yml new file mode 100644 index 00000000000..ed490c36245 --- /dev/null +++ b/config/gpu_configs/gpu_aquaplanet_dyamond_summer.yml @@ -0,0 +1,26 @@ +dt_save_state_to_disk: "Inf" +dt_save_to_sol: "Inf" +output_default_diagnostics: false +h_elem: 30 +z_max: 60000.0 +z_elem: 63 +dz_bottom: 30.0 +rayleigh_sponge: true +viscous_sponge: true +moist: "equil" +precip_model: "1M" +rad: "allskywithclear" +insolation: "timevarying" +dt_rad: "1hours" +dt_cloud_fraction: "1hours" +vert_diff: "FriersonDiffusion" +implicit_diffusion: true +approximate_linear_solve_iters: 2 +surface_setup: "DefaultMoninObukhov" +dt: "90secs" +t_end: "1days" +toml: [toml/longrun_aquaplanet.toml] +prescribe_ozone: true +aerosol_radiation: true +prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"] +initial_condition: "DYAMONDSummer" diff --git a/src/initial_conditions/initial_conditions.jl b/src/initial_conditions/initial_conditions.jl index c3f9edef999..00988970022 100644 --- a/src/initial_conditions/initial_conditions.jl +++ b/src/initial_conditions/initial_conditions.jl @@ -160,6 +160,31 @@ function (initial_condition::DecayingProfile)(params) return local_state end +""" + DYAMONDSummer(; perturb = true) + +An `InitialCondition` with a decaying temperature profile, and with an optional +perturbation to the temperature. +""" +struct DYAMONDSummer <: InitialCondition end + +function (initial_condition::DYAMONDSummer)(params) + function local_state(local_geometry) + FT = eltype(params) + grav = CAP.grav(params) + thermo_params = CAP.thermodynamics_params(params) + + T, p = FT(300), FT(100000) # placeholder values + + return LocalState(; + params, + geometry = local_geometry, + thermo_state = TD.PhaseDry_pT(thermo_params, p, T), + ) + end + return local_state +end + """ AgnesiHProfile(; perturb = false) diff --git a/src/solver/type_getters.jl b/src/solver/type_getters.jl index ba3faf9c3b0..3b3dbc7f252 100644 --- a/src/solver/type_getters.jl +++ b/src/solver/type_getters.jl @@ -1,6 +1,7 @@ using Dates: DateTime, @dateformat_str import Interpolations import NCDatasets +import ClimaUtilities import ClimaUtilities.OutputPathGenerator import ClimaCore: InputOutput, Meshes, Spaces, Quadratures import ClimaAtmos.RRTMGPInterface as RRTMGPI @@ -8,6 +9,9 @@ import ClimaAtmos as CA import LinearAlgebra import ClimaCore.Fields import ClimaTimeSteppers as CTS +import ClimaAtmos.AtmosArtifacts as AA +#using ClimaParams +import Thermodynamics as TD import ClimaDiagnostics @@ -267,6 +271,10 @@ function get_initial_condition(parsed_args) return getproperty(ICs, Symbol(parsed_args["initial_condition"]))( parsed_args["perturb_initstate"], ) + elseif parsed_args["initial_condition"] in ["DYAMONDSummer"] + return getproperty(ICs, Symbol(parsed_args["initial_condition"]))( + parsed_args["perturb_initstate"], + ) elseif parsed_args["initial_condition"] in [ "Nieuwstadt", "GABLS", @@ -616,7 +624,6 @@ end function get_simulation(config::AtmosConfig) params = create_parameter_set(config) atmos = get_atmos(config, params) - sim_info = get_sim_info(config) job_id = sim_info.job_id output_dir = sim_info.output_dir @@ -661,6 +668,80 @@ function get_simulation(config::AtmosConfig) tracers = get_tracers(config.parsed_args) + if initial_condition isa ClimaAtmos.InitialConditions.DYAMONDSummer + @show "DYAMONDSummer, initialize from file" + thermo_params = params.thermodynamics_params + file_path = AA.dyamond_summer_artifact_path(; + context = get_comms_context(config.parsed_args), + ) + Pressure = ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "p", + spaces.center_space, + ) + Temperature = ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "t", + spaces.center_space, + ) + q_tot = ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "q", + spaces.center_space, + ) + q = TD.PhasePartition.(q_tot) + Y.c.ρ .= TD.air_density.(thermo_params, Temperature, Pressure, q) + vel = + ClimaCore.Geometry.UVWVector.( + ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "u", + spaces.center_space, + ), + ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "v", + spaces.center_space, + ), + ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "w", + spaces.center_space, + ), + ) + Y.c.uₕ .= + ClimaCore.Geometry.Covariant12Vector.( + ClimaCore.Geometry.UVVector.(vel) + ) + Y.f.u₃ .= + ᶠinterp.( + ClimaCore.Geometry.Covariant3Vector.( + ClimaCore.Geometry.WVector.(vel) + ) + ) + e_kin = similar(Temperature) + compute_kinetic!(e_kin, Y.c.uₕ, Y.f.u₃) + e_pot = ClimaCore.Fields.coordinate_field(Y.c).z .* thermo_params.grav + Y.c.ρe_tot .= + TD.total_energy.(thermo_params, Temperature, e_kin, e_pot) .* Y.c.ρ + Y.c.ρq_tot .= q_tot .* Y.c.ρ + if config.parsed_args["precip_model"] == "1M" + Y.c.ρq_sno .= + ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "cswc", + spaces.center_space, + ) .* Y.c.ρ + Y.c.ρq_rai .= + ClimaUtilities.SpaceVaryingInputs.SpaceVaryingInput( + file_path, + "crwc", + spaces.center_space, + ) .* Y.c.ρ + end + @show "****************************" + end + s = @timed_str begin p = build_cache( Y, diff --git a/src/utils/AtmosArtifacts.jl b/src/utils/AtmosArtifacts.jl index 2a3092406c4..5879f8a476f 100644 --- a/src/utils/AtmosArtifacts.jl +++ b/src/utils/AtmosArtifacts.jl @@ -82,4 +82,12 @@ function earth_orography_file_path(; context = nothing) ) end +function dyamond_summer_artifact_path(; context = nothing) + filename = "DYAMOND_SUMMER_ICS_p98deg.nc" + return joinpath( + @clima_artifact("DYAMOND_SUMMER_ICS_p98deg", context), + filename, + ) +end + end