Skip to content

Commit

Permalink
Add Jupiter CRM (#103)
Browse files Browse the repository at this point in the history
add jupiter_crm to test case
  • Loading branch information
chengcli authored Oct 31, 2023
1 parent 146332f commit e2ae7e7
Show file tree
Hide file tree
Showing 40 changed files with 685 additions and 368 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ endif()

## 6. set up unit tests and examples
message(STATUS "6. Set up unit tests")

# load all macros
FILE(GLOB _macro_files "${CMAKE_SOURCE_DIR}/cmake/macros/*.cmake")
FOREACH(_file ${_macro_files})
MESSAGE(STATUS "Include ${_file}")
INCLUDE(${_file})
ENDFOREACH()

add_subdirectory(examples)
add_subdirectory(tests)

Expand Down
6 changes: 3 additions & 3 deletions cmake/sedimentation.cmake → cmake/jupiter_crm.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# configure file for test sedimentation
# configure file for test jupiter crm

macro(SET_IF_EMPTY _variable)
if("${${_variable}}" STREQUAL "")
Expand All @@ -10,8 +10,8 @@ endmacro()
set_if_empty(NUMBER_GHOST_CELLS 3)

# canoe configure
set(NVAPOR 2)
set(NCLOUD 4)
set(NVAPOR 1)
set(NCLOUD 2)
set(NPHASE_LEGACY 3)
set(NETCDF ON)
set(PNETCDF ON)
Expand Down
23 changes: 23 additions & 0 deletions cmake/macros/macro_setup_problem.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# A small macro used for setting up the build of a problem.
#
# Usage: setup_problem(name)

string(TOLOWER ${CMAKE_BUILD_TYPE} buildl)
string(TOUPPER ${CMAKE_BUILD_TYPE} buildu)

macro(setup_problem namel)
add_executable(${namel}.${buildl} ${namel}.cpp
${CMAKE_BINARY_DIR}/main_${TASK}.cpp)

set_target_properties(
${namel}.${buildl}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
COMPILE_FLAGS ${CMAKE_CXX_FLAGS_${buildu}})

target_link_libraries(${namel}.${buildl} ${CANOE_LIBRARY_${buildu}})

target_include_directories(
${namel}.${buildl}
PRIVATE ${CMAKE_BINARY_DIR} ${CANOE_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR}
${MPI_CXX_INCLUDE_PATH} ${NETCDF_INCLUDES} ${PNETCDF_INCLUDE_DIR})
endmacro()
31 changes: 31 additions & 0 deletions cmake/macros/macro_setup_test.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# A small macro used for setting up the build of a test.
#
# Usage: setup_test(name)

macro(setup_test namel)
string(TOLOWER ${CMAKE_BUILD_TYPE} buildl)
string(TOUPPER ${CMAKE_BUILD_TYPE} buildu)

add_executable(${namel}.${buildl} ${namel}.cpp globals.cpp)

set_target_properties(${namel}.${buildl}
PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_${buildu}})

target_include_directories(
${namel}.${buildl}
PRIVATE $<$<BOOL:${PVFMM}>:${PVFMM_SOURCE_DIR}/SCTL/include>
${CMAKE_BINARY_DIR}
${CANOE_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${MPI_CXX_INCLUDE_PATH}
${NETCDF_INCLUDES}
${PNETCDF_INCLUDE_DIR}
${OpenMP_CXX_INCLUDE_DIR}
${FFTW_INCLUDE_DIRS})

target_link_libraries(
${namel}.${buildl} gtest_main $<$<BOOL:${PVFMM}>:pvfmmStatic>
${CANOE_LIBRARY_${buildu}})

add_test(NAME ${namel}.${buildl} COMMAND ${namel}.${buildl})
endmacro()
60 changes: 12 additions & 48 deletions examples/2019-Li-snap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,20 @@
string(TOLOWER ${CMAKE_BUILD_TYPE} buildl)
string(TOUPPER ${CMAKE_BUILD_TYPE} buildu)
# ============================================
# Examples published in Li et al. (2019), ApJS
# ============================================

macro(setup_problem namel)
set_target_properties(
${namel}.${buildl}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
COMPILE_FLAGS ${CMAKE_CXX_FLAGS_${buildu}}
)
# 1. Compile straka, robert and bryan
setup_problem(straka)
setup_problem(robert)
setup_problem(bryan)

target_link_libraries(${namel}.${buildl}
${CANOE_LIBRARY_${buildu}}
)

target_include_directories(${namel}.${buildl}
PRIVATE
${CMAKE_BINARY_DIR}
${CANOE_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${MPI_CXX_INCLUDE_PATH}
${NETCDF_INCLUDES}
${PNETCDF_INCLUDE_DIR}
)
endmacro()

# 1. Compile straka and robert
foreach(namel straka robert)
add_executable(${namel}.${buildl} ${namel}.cpp
${CMAKE_BINARY_DIR}/main_${TASK}.cpp)
setup_problem(${namel})
endforeach()

# 2. Compile bryan
if (${NVAPOR} EQUAL 1 AND ${NCLOUD} EQUAL 1 AND ${NPHASE_LEGACY} EQUAL 2)
set(namel bryan)

add_executable(${namel}.${buildl} ${namel}_pgen.cpp ${namel}_mods.cpp
${CMAKE_BINARY_DIR}/main_${TASK}.cpp)

setup_problem(${namel})
endif()

# 3. Compile sedimentation
# 2. Compile sedimentation
if (${NVAPOR} EQUAL 2 AND ${NCLOUD} EQUAL 4 AND ${NPHASE_LEGACY} EQUAL 3)
set(namel sedimentation)

add_executable(${namel}.${buildl} ${namel}.cpp ../giants_enroll_vapor_functions.cpp
${CMAKE_BINARY_DIR}/main_${TASK}.cpp)

setup_problem(${namel})
setup_problem(sedimentation)
endif()

# 3. Compile jupiter crm
setup_problem(jupiter_crm)

# 4. Copy input files to run directory
file(GLOB inputs *.inp *.yaml)
foreach(input ${inputs})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
// snap
#include <snap/thermodynamics/thermodynamics.hpp>

// special includes
#include "bryan_vapor_functions.hpp"

int iH2O, iH2Oc;
Real p0, grav;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ double sat_vapor_p_H2O(double T) {
return SatVaporPresIdeal(T / tr, pr, betal, gammal);
}

void Thermodynamics::enrollVaporFunctions() { enrollVaporFunctionH2O(); }

// water svp
void Thermodynamics::enrollVaporFunctionH2O() {
void enroll_vapor_Function_H2O(Thermodynamics::SVPFunc1Container &svp_func1) {
Application::Logger app("snap");
app->Log("Enrolling H2O vapor pressures");

auto pindex = IndexMap::GetInstance();
int iH2O = pindex->GetVaporId("H2O");

svp_func1_[iH2O][0] = [](AirParcel const &qfrac, int, int) {
svp_func1[iH2O][0] = [](AirParcel const &qfrac, int, int) {
return sat_vapor_p_H2O(qfrac.w[IDN]);
};
}

void Thermodynamics::enrollVaporFunctions() {
enroll_vapor_Function_H2O(svp_func1_);
}
99 changes: 99 additions & 0 deletions examples/2019-Li-snap/jupiter2d.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<comment>
problem = test jupiter

<job>
problem_id = jupiter2d # problem ID: basename of output filenames

<output0>
file_type = rst
dt = 10.E5

<output1>
file_type = hst # History data dump
dt = 2.E4 # time increment between outputs

<output2>
file_type = netcdf # Netcdf format output
variable = prim # variables to be output
dt = 1.E4 # time increment between outputs

<output3>
file_type = netcdf # Netcdf format output
variable = uov # diagnostic variables
dt = 1.E4 # time increment

<time>
cfl_number = 0.9
nlim = -1 # cycle limit
tlim = 2.E5
xorder = 5 # horizontal reconstruction order
integrator = rk3 # integration method

<mesh>
nx1 = 80 # Number of zones in X1-direction
x1min = -320.E3 # minimum value of X1
x1max = 40.E3 # maximum value of X1
ix1_bc = reflecting # Inner-X1 boundary condition flag
ox1_bc = reflecting # Outer-X1 boundary condition flag

nx2 = 320 # Number of zones in X2-direction
x2min = 0. # minimum value of X2
x2max = 3200.E3 # maximum value of X2
ix2_bc = periodic # Inner-X2 boundary condition flag
ox2_bc = periodic # Outer-X2 boundary condition flag

nx3 = 1 # Number of zones in X3-direction
x3min = -0.5 # minimum value of X3
x3max = 0.5 # maximum value of X3
ix3_bc = periodic # Inner-X3 boundary condition flag
ox3_bc = periodic # Outer-X3 boundary condition flag

<meshblock>
nx1 = 80
nx2 = 40
nx3 = 1

<hydro>
gamma = 1.42
grav_acc1 = -24.79
implicit_flag = 1

#<species>
#vapor = H2O, NH3
#cloud = H2O(c), NH3(c), H2O(p), NH3(p)

<species>
vapor = H2O
cloud = H2O(c), H2O(p)

<chemistry>
microphysics_config = water_ammonia.yaml

<thermodynamics>
Rd = 3777. # mu = 2.3175 g/mol
eps1 = 8.18 8.18 8.18
beta1 = 0. 24.845 24.845
rcp1 = 0.15 0.33 0.33
Ttriple1 = 273.16
Ptriple1 = 611.7

eps2 = 7.72 7.72 7.72
rcp2 = 0.078 0.16 0.16
beta2 = 0. 23.67 23.67
Ttriple2 = 195.4
Ptriple2 = 6060.

sa.relax = 1.0
sa.max_iter = 4
sa.ftol = 1.e-2

<problem>
qH2O.ppmv = 25000.
qNH3.ppmv = 320.

P0 = 1.E5
T0 = 169.
Tmin = 110.
hrate = -100.
prad = 2.e5
init_Ttol = 2.
Loading

0 comments on commit e2ae7e7

Please sign in to comment.