Skip to content

Commit

Permalink
Moisture source term profiles for BOMEX (erf-model#1466)
Browse files Browse the repository at this point in the history
* Moisture source term profiles for BOMEX

* Formatting fixes only.

* This starts but dies from touching uninitialized data.

* qv is updated in post, move the sources there.

---------

Co-authored-by: Chandru Dhandapani <chandru@x1000c5s2b1n1.hsn.cm.kestrel.hpc.nrel.gov>
Co-authored-by: AMLattanzi <AMLattanzi@lbl.gov>
Co-authored-by: Aaron M. Lattanzi <103702284+AMLattanzi@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 7, 2024
1 parent ec69524 commit d2432b9
Show file tree
Hide file tree
Showing 21 changed files with 609 additions and 30 deletions.
12 changes: 12 additions & 0 deletions Exec/DevTests/Bomex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(erf_exe_name erf_abl_with_temperature_source)

add_executable(${erf_exe_name} "")
target_sources(${erf_exe_name}
PRIVATE
prob.cpp
)

target_include_directories(${erf_exe_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

include(${CMAKE_SOURCE_DIR}/CMake/BuildERFExe.cmake)
build_erf_exe(${erf_exe_name})
34 changes: 34 additions & 0 deletions Exec/DevTests/Bomex/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# AMReX
COMP = gnu
PRECISION = DOUBLE

# Profiling
PROFILE = FALSE
TINY_PROFILE = TRUE
COMM_PROFILE = FALSE
TRACE_PROFILE = FALSE
MEM_PROFILE = FALSE
USE_GPROF = FALSE

# Performance
USE_MPI = TRUE
USE_OMP = FALSE

USE_CUDA = FALSE
USE_HIP = FALSE
USE_SYCL = FALSE

# Debugging
DEBUG = FALSE

TEST = TRUE
USE_ASSERTION = TRUE

#USE_POISSON_SOLVE = TRUE

# GNU Make
Bpack := ./Make.package
Blocs := .
ERF_HOME := ../../..
ERF_PROBLEM_DIR = $(ERF_HOME)/Exec/DevTests/Bomex
include $(ERF_HOME)/Exec/Make.ERF
2 changes: 2 additions & 0 deletions Exec/DevTests/Bomex/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CEXE_headers += prob.H
CEXE_sources += prob.cpp
1 change: 1 addition & 0 deletions Exec/DevTests/Bomex/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a copy of the DEvtests/TemperatureSource problem, but with update_rhoQ1_sources added
77 changes: 77 additions & 0 deletions Exec/DevTests/Bomex/input_SAM
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
stop_time = 21600

amrex.fpe_trap_invalid = 1

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
geometry.prob_extent = 6400 6400 3000
amr.n_cell = 64 64 75

geometry.is_periodic = 1 1 0

# MOST BOUNDARY (DEFAULT IS ADIABATIC FOR THETA)
zlo.type = "Most"

erf.most.z0 = 0.000283
erf.most.zref = 20.0
erf.most.surf_temp_flux = 0.008

zhi.type = "SlipWall"

# TIME STEP CONTROL
erf.fixed_dt = 1.0 # fixed time step depending on grid resolution

# DIAGNOSTICS & VERBOSITY
erf.sum_interval = 1 # timesteps between computing mass
erf.v = 1 # verbosity in ERF.cpp
amr.v = 1 # verbosity in Amr.cpp

# REFINEMENT / REGRIDDING
amr.max_level = 0 # maximum level number allowed

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_int = 600 # number of timesteps between checkpoints

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 60 # number of timesteps between plotfiles
erf.plot_vars_1 = density rhotheta x_velocity y_velocity z_velocity pressure temp theta qt qp qv qc qi

# SOLVER CHOICE
erf.alpha_T = 0.0
erf.alpha_C = 1.0
erf.use_gravity = false

erf.moisture_model = "SAM"

erf.molec_diff_type = "None"
erf.les_type = "Smagorinsky"
erf.Cs = 0.1

erf.init_type = "input_sounding"
erf.init_sounding_ideal = true

erf.add_custom_rhotheta_forcing = true
erf.add_custom_moisture_forcing = true
erf.custom_forcing_uses_primitive_vars = false

# Higher values of perturbations lead to instability
# Instability seems to be coming from BC
prob.U_0_Pert_Mag = 0.01
prob.V_0_Pert_Mag = 0.01
prob.W_0_Pert_Mag = 0.0

prob.pert_ref_height = 400.0
prob.T_pert = 0.1
prob.qv_pert = 0.025

prob.advection_heating_rate = -2.3148E-5
prob.source_cutoff = 1500.0
prob.source_cutoff_transition = 3000.0

prob.advection_moisture_rate = -1.2E-8
prob.moisture_source_cutoff = 300.0
prob.moisture_source_cutoff_transition = 500.0
7 changes: 7 additions & 0 deletions Exec/DevTests/Bomex/input_sounding
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1015. 298.7 17.0
0.0 298.700 17.00 -8.750 0.0
520.0 298.700 16.30 -8.750 0.0
700.0 299.394 15.25 -8.750 0.0
1480.0 302.400 10.70 -7.346 0.0
2000.0 308.200 4.20 -6.410 0.0
3000.0 311.850 3.00 -4.610 0.0
106 changes: 106 additions & 0 deletions Exec/DevTests/Bomex/prob.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#ifndef _PROB_H_
#define _PROB_H_

#include <string>

#include "AMReX_REAL.H"

#include "prob_common.H"

struct ProbParm : ProbParmDefaults {
amrex::Real rho_0 = 0.0;
amrex::Real T_0 = 0.0;
amrex::Real A_0 = 1.0;
amrex::Real QKE_0 = 0.1;

amrex::Real U_0 = 0.0;
amrex::Real V_0 = 0.0;
amrex::Real W_0 = 0.0;

// random initial perturbations (legacy code)
amrex::Real U_0_Pert_Mag = 0.0;
amrex::Real V_0_Pert_Mag = 0.0;
amrex::Real W_0_Pert_Mag = 0.0;
amrex::Real T_0_Pert_Mag = 0.0; // perturbation to rho*Theta

// divergence-free initial perturbations
amrex::Real pert_deltaU = 0.0;
amrex::Real pert_deltaV = 0.0;
amrex::Real pert_periods_U = 5.0;
amrex::Real pert_periods_V = 5.0;
amrex::Real pert_ref_height = 100.0;

// rayleigh damping
amrex::Real dampcoef = 0.2; // inverse time scale [1/s]
amrex::Real zdamp = 500.0; // damping depth [m] from model top

//==============================================
// USER-DEFINED INPUTS
// source terms
amrex::Real advection_heating_rate = 0.0;
amrex::Real restart_time = 9e9;
amrex::Real cutoff = 500.0;
amrex::Real cutoff_transition = 50.0;

amrex::Real advection_moisture_rate = 0.0;
amrex::Real moisture_cutoff = 500.0;
amrex::Real moisture_cutoff_transition = 50.0;
//==============================================

// helper vars
amrex::Real aval;
amrex::Real bval;
amrex::Real ufac;
amrex::Real vfac;
}; // namespace ProbParm

class Problem : public ProblemBase
{
public:
Problem (const amrex::Real* problo, const amrex::Real* probhi);

#include "Prob/init_constant_density_hse.H"
#include "Prob/init_rayleigh_damping.H"

void init_custom_pert (
const amrex::Box& bx,
const amrex::Box& xbx,
const amrex::Box& ybx,
const amrex::Box& zbx,
amrex::Array4<amrex::Real > const& state,
amrex::Array4<amrex::Real > const& x_vel,
amrex::Array4<amrex::Real > const& y_vel,
amrex::Array4<amrex::Real > const& z_vel,
amrex::Array4<amrex::Real > const& r_hse,
amrex::Array4<amrex::Real > const& p_hse,
amrex::Array4<amrex::Real const> const& z_nd,
amrex::Array4<amrex::Real const> const& z_cc,
amrex::GeometryData const& geomdata,
amrex::Array4<amrex::Real const> const& mf_m,
amrex::Array4<amrex::Real const> const& mf_u,
amrex::Array4<amrex::Real const> const& mf_v,
const SolverChoice& sc) override;

void update_rhotheta_sources (
const amrex::Real& /*time*/,
amrex::Vector<amrex::Real>& src,
amrex::Gpu::DeviceVector<amrex::Real>& d_src,
const amrex::Geometry& geom,
std::unique_ptr<amrex::MultiFab>& z_phys_cc) override;

void update_rhoqt_sources (
const amrex::Real& /*time*/,
amrex::Vector<amrex::Real>& qsrc,
amrex::Gpu::DeviceVector<amrex::Real>& d_qsrc,
const amrex::Geometry& geom,
std::unique_ptr<amrex::MultiFab>& z_phys_cc) override;

protected:
std::string name () override { return "BOMEX"; }

private:
ProbParm parms;
amrex::Vector<amrex::Real> zlevels;
};

#endif
Loading

0 comments on commit d2432b9

Please sign in to comment.