Skip to content

Commit

Permalink
more cleanup; no change in functionality expected (#1930)
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren authored Nov 6, 2024
1 parent d55d717 commit 72bf212
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 139 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ target_link_libraries(erf_api PUBLIC erf_srclib)
add_library(${PROJECT_NAME}::erf_api ALIAS erf_srclib)

# Collect all headers and make them installable with the target
set(ERF_INCLUDES "Source/ERF.H;Source/ERF_Constants.H;Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H;Source/WindFarmParametrization/EWP/ERF_EWP.H;Source/WindFarmParametrization/Null/ERF_NullWindFarm.H;Source/WindFarmParametrization/ERF_WindFarm.H;Source/WindFarmParametrization/Fitch/ERF_Fitch.H;Source/BoundaryConditions/ERF_PhysBCFunct.H;Source/BoundaryConditions/ERF_MOSTAverage.H;Source/BoundaryConditions/ERF_MOSTRoughness.H;Source/BoundaryConditions/ERF_ABLMost.H;Source/BoundaryConditions/ERF_FillPatcher.H;Source/BoundaryConditions/ERF_MOSTStress.H;Source/BoundaryConditions/ERF_TimeInterpolatedData.H;Source/Utils/ERF_Interpolation.H;Source/Utils/ERF_TileNoZ.H;Source/Utils/ERF_PlaneAverage.H;Source/Utils/ERF_Interpolation_WENO.H;Source/Utils/ERF_DirectionSelector.H;Source/Utils/ERF_ParFunctions.H;Source/Utils/ERF_Wstar.H;Source/Utils/ERF_Microphysics_Utils.H;Source/Utils/ERF_Sat_methods.H;Source/Utils/ERF_Interpolation_1D.H;Source/Utils/ERF_Interpolation_UPW.H;Source/Utils/ERF_TerrainMetrics.H;Source/Utils/ERF_Interpolation_WENO_Z.H;Source/Utils/ERF_Thetav.H;Source/Utils/ERF_Water_vapor_saturation.H;Source/Utils/ERF_Utils.H;Source/Utils/ERF_Orbit.H;Source/Utils/ERF_EOS.H;Source/Utils/ERF_HSE_utils.H;Source/EB/ERF_TerrainIF.H;Source/EB/ERF_FlowerIF.H;Source/EB/ERF_eb_if.H;Source/Particles/ERFPC.H;Source/Particles/ERF_ParticleData.H;Source/Prob/ERF_init_density_hse_dry.H;Source/Prob/ERF_init_rayleigh_damping.H;Source/Prob/ERF_init_constant_density_hse.H;Source/ERF_prob_common.H;Source/ERF_Derive.H;Source/Radiation/ERF_Mam4_constituents.H;Source/Radiation/ERF_Mam4_aero.H;Source/Radiation/ERF_Optics.H;Source/Radiation/ERF_Modal_aero_wateruptake.H;Source/Radiation/ERF_Cloud_rad_props.H;Source/Radiation/ERF_Phys_prop.H;Source/Radiation/ERF_Radiation.H;Source/Radiation/ERF_Albedo.H;Source/Radiation/ERF_Parameterizations.H;Source/Radiation/ERF_Rad_constants.H;Source/Radiation/ERF_Aero_rad_props.H;Source/Radiation/ERF_m2005_effradius.H;Source/Radiation/ERF_Linear_interpolate.H;Source/Radiation/ERF_Slingo.H;Source/Radiation/ERF_Rrtmgp.H;Source/Radiation/ERF_Ebert_curry.H;Source/SourceTerms/ERF_NumericalDiffusion.H;Source/SourceTerms/ERF_Src_headers.H;Source/IO/ERF_NCInterface.H;Source/IO/ERF_NCWpsFile.H;Source/IO/ERF_NCPlotFile.H;Source/IO/ERF_ReadBndryPlanes.H;Source/IO/ERF_WriteBndryPlanes.H;Source/PBL/ERF_MYNNStruct.H;Source/PBL/ERF_PBLModels.H;Source/PBL/ERF_PBLHeight.H;Source/TimeIntegration/ERF_TI_fast_rhs_fun.H;Source/TimeIntegration/ERF_TI_slow_headers.H;Source/TimeIntegration/ERF_TI_slow_rhs_fun.H;Source/TimeIntegration/ERF_TI_fast_headers.H;Source/TimeIntegration/ERF_TI_utils.H;Source/TimeIntegration/ERF_MRI.H;Source/TimeIntegration/ERF_TI_no_substep_fun.H;Source/LandSurfaceModel/Null/ERF_NullSurf.H;Source/LandSurfaceModel/ERF_LandSurface.H;Source/LandSurfaceModel/MM5/ERF_MM5.H;Source/LandSurfaceModel/SLM/ERF_SLM.H;Source/ERF_IndexDefines.H;Source/Advection/ERF_AdvectionSrcForMom_N.H;Source/Advection/ERF_AdvectionSrcForScalars.H;Source/Advection/ERF_AdvectionSrcForMom_T.H;Source/Advection/ERF_Advection.H;Source/MultiBlock/ERF_MultiBlockContainer.H;Source/Initialization/ERF_Metgrid_utils.H;Source/Diffusion/ERF_EddyViscosity.H;Source/Diffusion/ERF_Diffusion.H;Source/Microphysics/Null/ERF_NullMoistLagrangian.H;Source/Microphysics/Null/ERF_NullMoist.H;Source/Microphysics/ERF_Microphysics.H;Source/Microphysics/ERF_LagrangianMicrophysics.H;Source/Microphysics/ERF_EulerianMicrophysics.H;Source/Microphysics/Kessler/ERF_Kessler.H;Source/Microphysics/SAM/ERF_SAM.H;Source/DataStructs/ERF_InputSpongeData.H;Source/DataStructs/ERF_TurbPertStruct.H;Source/DataStructs/ERF_SpongeStruct.H;Source/DataStructs/ERF_AdvStruct.H;Source/DataStructs/ERF_DataStruct.H;Source/DataStructs/ERF_InputSoundingData.H;Source/DataStructs/ERF_DiffStruct.H;Source/DataStructs/ERF_TurbStruct.H")
set(ERF_INCLUDES "Source/ERF.H;Source/ERF_Constants.H;Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H;Source/WindFarmParametrization/EWP/ERF_EWP.H;Source/WindFarmParametrization/Null/ERF_NullWindFarm.H;Source/WindFarmParametrization/ERF_WindFarm.H;Source/WindFarmParametrization/Fitch/ERF_Fitch.H;Source/BoundaryConditions/ERF_PhysBCFunct.H;Source/BoundaryConditions/ERF_MOSTAverage.H;Source/BoundaryConditions/ERF_MOSTRoughness.H;Source/BoundaryConditions/ERF_ABLMost.H;Source/BoundaryConditions/ERF_FillPatcher.H;Source/BoundaryConditions/ERF_MOSTStress.H;Source/BoundaryConditions/ERF_TimeInterpolatedData.H;Source/Utils/ERF_Interpolation.H;Source/Utils/ERF_TileNoZ.H;Source/Utils/ERF_PlaneAverage.H;Source/Utils/ERF_Interpolation_WENO.H;Source/Utils/ERF_DirectionSelector.H;Source/Utils/ERF_ParFunctions.H;Source/Utils/ERF_Wstar.H;Source/Utils/ERF_Microphysics_Utils.H;Source/Utils/ERF_Sat_methods.H;Source/Utils/ERF_Interpolation_1D.H;Source/Utils/ERF_Interpolation_UPW.H;Source/Utils/ERF_TerrainMetrics.H;Source/Utils/ERF_Interpolation_WENO_Z.H;Source/Utils/ERF_Thetav.H;Source/Utils/ERF_Water_vapor_saturation.H;Source/Utils/ERF_Utils.H;Source/Utils/ERF_Orbit.H;Source/Utils/ERF_EOS.H;Source/Utils/ERF_HSE_utils.H;Source/EB/ERF_TerrainIF.H;Source/EB/ERF_FlowerIF.H;Source/EB/ERF_eb_if.H;Source/Particles/ERFPC.H;Source/Particles/ERF_ParticleData.H;Source/Prob/ERF_init_density_hse_dry.H;Source/Prob/ERF_init_rayleigh_damping.H;Source/Prob/ERF_init_constant_density_hse.H;Source/ERF_prob_common.H;Source/ERF_Derive.H;Source/Radiation/ERF_Mam4_constituents.H;Source/Radiation/ERF_Mam4_aero.H;Source/Radiation/ERF_Optics.H;Source/Radiation/ERF_Modal_aero_wateruptake.H;Source/Radiation/ERF_Cloud_rad_props.H;Source/Radiation/ERF_Phys_prop.H;Source/Radiation/ERF_Radiation.H;Source/Radiation/ERF_Albedo.H;Source/Radiation/ERF_Parameterizations.H;Source/Radiation/ERF_Rad_constants.H;Source/Radiation/ERF_Aero_rad_props.H;Source/Radiation/ERF_m2005_effradius.H;Source/Radiation/ERF_Linear_interpolate.H;Source/Radiation/ERF_Slingo.H;Source/Radiation/ERF_Rrtmgp.H;Source/Radiation/ERF_Ebert_curry.H;Source/SourceTerms/ERF_NumericalDiffusion.H;Source/SourceTerms/ERF_Src_headers.H;Source/IO/ERF_NCInterface.H;Source/IO/ERF_NCWpsFile.H;Source/IO/ERF_NCPlotFile.H;Source/IO/ERF_ReadBndryPlanes.H;Source/IO/ERF_WriteBndryPlanes.H;Source/PBL/ERF_MYNNStruct.H;Source/PBL/ERF_PBLModels.H;Source/PBL/ERF_PBLHeight.H;Source/TimeIntegration/ERF_TI_substep_fun.H;Source/TimeIntegration/ERF_TI_slow_headers.H;Source/TimeIntegration/ERF_TI_slow_rhs_fun.H;Source/TimeIntegration/ERF_TI_fast_headers.H;Source/TimeIntegration/ERF_TI_utils.H;Source/TimeIntegration/ERF_MRI.H;Source/TimeIntegration/ERF_TI_no_substep_fun.H;Source/LandSurfaceModel/Null/ERF_NullSurf.H;Source/LandSurfaceModel/ERF_LandSurface.H;Source/LandSurfaceModel/MM5/ERF_MM5.H;Source/LandSurfaceModel/SLM/ERF_SLM.H;Source/ERF_IndexDefines.H;Source/Advection/ERF_AdvectionSrcForMom_N.H;Source/Advection/ERF_AdvectionSrcForScalars.H;Source/Advection/ERF_AdvectionSrcForMom_T.H;Source/Advection/ERF_Advection.H;Source/MultiBlock/ERF_MultiBlockContainer.H;Source/Initialization/ERF_Metgrid_utils.H;Source/Diffusion/ERF_EddyViscosity.H;Source/Diffusion/ERF_Diffusion.H;Source/Microphysics/Null/ERF_NullMoistLagrangian.H;Source/Microphysics/Null/ERF_NullMoist.H;Source/Microphysics/ERF_Microphysics.H;Source/Microphysics/ERF_LagrangianMicrophysics.H;Source/Microphysics/ERF_EulerianMicrophysics.H;Source/Microphysics/Kessler/ERF_Kessler.H;Source/Microphysics/SAM/ERF_SAM.H;Source/DataStructs/ERF_InputSpongeData.H;Source/DataStructs/ERF_TurbPertStruct.H;Source/DataStructs/ERF_SpongeStruct.H;Source/DataStructs/ERF_AdvStruct.H;Source/DataStructs/ERF_DataStruct.H;Source/DataStructs/ERF_InputSoundingData.H;Source/DataStructs/ERF_DiffStruct.H;Source/DataStructs/ERF_TurbStruct.H")
set_target_properties(
erf_srclib PROPERTIES PUBLIC_HEADER "${ERF_INCLUDES}")

Expand Down
40 changes: 9 additions & 31 deletions Exec/MoistRegTests/Bubble/ERF_prob.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ERF_prob.H"
#include "ERF_Microphysics_Utils.H"
#include "ERF_Constants.H"
#include "ERF_EOS.H"

using namespace amrex;

Expand Down Expand Up @@ -52,13 +53,6 @@ Real compute_relative_humidity ()
return 1.0;
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real compute_vapor_pressure (const Real p_s, const Real RH)
{
return p_s*RH;
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real vapor_mixing_ratio (const Real p_b, const Real T_b, const Real RH)
Expand Down Expand Up @@ -118,30 +112,20 @@ Real compute_dewpoint_temperature (const Real T_b, const Real RH)
return T_dp;
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real Problem::compute_theta(const Real T_b, const Real p_b)
{
return T_b*std::pow(p_0/p_b, R_d/Cp_d);
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real compute_temperature_from_theta(const Real theta, const Real p)
{
return theta*std::pow(p/p_0, R_d/Cp_d);
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
void Problem::compute_rho (const Real& pressure, Real& theta, Real& rho, Real& q_v, Real& T_dp, Real& T_b)
{
T_b = compute_temperature(pressure);
theta = compute_theta(T_b, pressure);

theta = getThgivenPandT(T_b, pressure, (R_d/Cp_d));

Real RH = compute_relative_humidity();
q_v = vapor_mixing_ratio(pressure, T_b, RH);
rho = pressure/(R_d*T_b*(1.0 + (R_v/R_d)*q_v));

rho = getRhogivenTandPress(T_b, pressure, q_v);
rho = rho*(1.0 + parms.qt_init); // q_t = 0.02 a given constant for this test case

T_dp = compute_dewpoint_temperature(T_b, RH);
}

Expand Down Expand Up @@ -228,16 +212,10 @@ Problem::erf_init_dens_hse_moist (MultiFab& rho_hse,
Vector<Real> h_q_v(khi+2);

Gpu::DeviceVector<Real> d_r(khi+2);
Gpu::DeviceVector<Real> d_p(khi+2);
Gpu::DeviceVector<Real> d_t(khi+2);
Gpu::DeviceVector<Real> d_q_v(khi+2);

init_isentropic_hse_no_terrain(h_t.data(), h_r.data(),h_p.data(), h_q_v.data(), dz, khi);

Gpu::copyAsync(Gpu::hostToDevice, h_r.begin(), h_r.end(), d_r.begin());
Gpu::copyAsync(Gpu::hostToDevice, h_p.begin(), h_p.end(), d_p.begin());
Gpu::copyAsync(Gpu::hostToDevice, h_t.begin(), h_t.end(), d_t.begin());
Gpu::copyAsync(Gpu::hostToDevice, h_q_v.begin(), h_q_v.end(), d_q_v.begin());

Real* r = d_r.data();

Expand Down Expand Up @@ -392,13 +370,13 @@ Problem::init_custom_pert(
}

theta_total = theta_back[k]*(delta_theta/300.0 + 1);
Real T = compute_temperature_from_theta(theta_total, p_back[k]);
Real T = getTgivenPandTh(theta_total, p_back[k], (R_d/Cp_d));
rho = p_back[k]/(R_d*T*(1.0 + (R_v/R_d)*q_v_back[k]));
RH = compute_relative_humidity();
Real q_v_hot = vapor_mixing_ratio(p_back[k], T, RH);

// Compute background quantities
Real T_back = compute_temperature_from_theta(theta_back[k], p_back[k]);
Real T_back = getTgivenPandTh(theta_back[k], p_back[k], (R_d/Cp_d));
Real rho_back = p_back[k]/(R_d*T_back*(1.0 + (R_v/R_d)*q_v_back[k]));

// This version perturbs rho but not p
Expand Down
46 changes: 11 additions & 35 deletions Exec/MoistRegTests/SquallLine_2D/ERF_prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ Real compute_relative_humidity (const Real z, const Real height, const Real z_tr
}
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real compute_vapor_pressure (const Real p_s, const Real RH)
{
return p_s*RH;
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real vapor_mixing_ratio (const Real z, const Real height, const Real p_b, const Real T_b, const Real RH)
Expand All @@ -92,13 +85,6 @@ Real vapor_mixing_ratio (const Real z, const Real height, const Real p_b, const
}
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real compute_temperature (const Real p_b, const Real theta_b)
{
return theta_b*std::pow(p_b/p_0,R_d/Cp_d);
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real compute_dewpoint_temperature (const Real T_b, const Real RH)
Expand All @@ -119,10 +105,10 @@ void Problem::compute_rho (const Real& z, const Real& pressure, Real& theta, Rea
{

theta = compute_theta(z);
T_b = compute_temperature(pressure, theta);
T_b = getTgivenPandTh(theta, pressure, (R_d/Cp_d));
Real RH = compute_relative_humidity(z, parms.height, parms.z_tr, pressure, T_b);
q_v = vapor_mixing_ratio(z, parms.height, pressure, T_b, RH);
rho = pressure/(R_d*T_b*(1.0 + (R_v/R_d)*q_v));
rho = getRhogivenTandPress(T_b, pressure, q_v);
rho = rho*(1.0 + q_v);
T_dp = compute_dewpoint_temperature(T_b, RH);
}
Expand Down Expand Up @@ -168,26 +154,19 @@ Problem::init_isentropic_hse_no_terrain(Real *theta, Real* r, Real* p, Real *q_v
const Real& dz, const Real& prob_lo_z,
const int& khi)
{

//FILE *file_IC;
//file_IC = fopen("input_sounding_probcpp.txt","w");
Real z, T_b, T_dp;

// Compute the quantities at z = 0.5*dz (first cell center)
z = prob_lo_z + 0.5*dz;
p[0] = p_0;
compute_p_k(p[0], p_0, theta[0], r[0], q_v[0], T_dp, T_b, dz, z, 0.0);
//fprintf(file_IC, "%0.15g %0.15g %0.15g %0.15g %0.15g %0.15g %0.15g\n", z, T_b-273.15, T_dp, p[0], r[0], theta[0], q_v[0]);


for (int k=1;k<=khi;k++){
z = prob_lo_z + (k+0.5)*dz;
p[k] = p[k-1];
compute_p_k(p[k], p[k-1], theta[k], r[k], q_v[k], T_dp, T_b, dz, z, r[k-1]);
//fprintf(file_IC, "%0.15g %0.15g %0.15g %0.15g %0.15g %0.15g %0.15g\n", z, T_b-273.15, T_dp, p[k], r[k], theta[k], q_v[k]);
}
//fclose(file_IC);


r[khi+1] = r[khi];
}
Expand Down Expand Up @@ -239,17 +218,11 @@ Problem::erf_init_dens_hse_moist (MultiFab& rho_hse,
Vector<Real> h_t(khi+2);
Vector<Real> h_q_v(khi+2);

amrex::Gpu::DeviceVector<Real> d_r(khi+2);
amrex::Gpu::DeviceVector<Real> d_p(khi+2);
amrex::Gpu::DeviceVector<Real> d_t(khi+2);
amrex::Gpu::DeviceVector<Real> d_q_v(khi+2);

init_isentropic_hse_no_terrain(h_t.data(), h_r.data(),h_p.data(), h_q_v.data(), dz,prob_lo_z,khi);

amrex::Gpu::DeviceVector<Real> d_r(khi+2);

amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_r.begin(), h_r.end(), d_r.begin());
amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_p.begin(), h_p.end(), d_p.begin());
amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_t.begin(), h_t.end(), d_t.begin());
amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_q_v.begin(), h_q_v.end(), d_q_v.begin());

Real* r = d_r.data();

Expand Down Expand Up @@ -352,15 +325,18 @@ Problem::init_custom_pert (
}

theta_total = t[k] + delta_theta;
temperature = compute_temperature(p[k], theta_total);
Real T_b = compute_temperature(p[k], t[k]);

temperature = getTgivenPandTh(theta_total, p[k], (R_d/Cp_d));
Real T_b = getTgivenPandTh(t[k] , p[k], (R_d/Cp_d));

RH = compute_relative_humidity(z, height, z_tr, p[k], T_b);
Real q_v_hot = vapor_mixing_ratio(z, height, p[k], T_b, RH);
rho = p[k]/(R_d*temperature*(1.0 + (R_v/R_d)*q_v_hot));

// Compute background quantities
Real temperature_back = compute_temperature(p[k], t[k]);
Real T_back = compute_temperature(p[k], t[k]);
Real temperature_back = getTgivenPandTh(t[k], p[k], (R_d/Cp_d));
Real T_back = getTgivenPandTh(t[k], p[k], (R_d/Cp_d));

Real RH_back = compute_relative_humidity(z, height, z_tr, p[k], T_back);
Real q_v_back = vapor_mixing_ratio(z, height, p[k], T_back, RH_back);
Real rho_back = p[k]/(R_d*temperature_back*(1.0 + (R_v/R_d)*q_v_back));
Expand Down
42 changes: 11 additions & 31 deletions Exec/MoistRegTests/SuperCell_3D/ERF_prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ Real compute_relative_humidity (const Real z, const Real height, const Real z_tr
}
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real compute_vapor_pressure (const Real p_s, const Real RH)
{
return p_s*RH;
}

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
Real vapor_mixing_ratio (const Real z, const Real height, const Real p_b, const Real T_b, const Real RH)
Expand Down Expand Up @@ -121,11 +114,13 @@ void Problem::compute_rho (const Real& z, const Real& pressure, Real& theta, Rea
{

theta = compute_theta(z);
T_b = compute_temperature(pressure, theta);
T_b = getTgivenPandTh(theta, pressure, (R_d/Cp_d));
Real RH = compute_relative_humidity(z, parms.height, parms.z_tr, pressure, T_b);
q_v = vapor_mixing_ratio(z, parms.height, pressure, T_b, RH);
rho = pressure/(R_d*T_b*(1.0 + (R_v/R_d)*q_v));

rho = getRhogivenTandPress(T_b, pressure, q_v);
rho = rho*(1.0 + q_v);

T_dp = compute_dewpoint_temperature(T_b, RH);
}

Expand Down Expand Up @@ -170,26 +165,19 @@ Problem::init_isentropic_hse_no_terrain(Real *theta, Real* r, Real* p, Real *q_v
const Real& dz, const Real& prob_lo_z,
const int& khi)
{

//FILE *file_IC;
//file_IC = fopen("input_sounding_probcpp.txt","w");
Real z, T_b, T_dp;

// Compute the quantities at z = 0.5*dz (first cell center)
z = prob_lo_z + 0.5*dz;
p[0] = p_0;
compute_p_k(p[0], p_0, theta[0], r[0], q_v[0], T_dp, T_b, dz, z, 0.0);
//fprintf(file_IC, "%0.15g %0.15g %0.15g %0.15g %0.15g %0.15g %0.15g\n", z, T_b-273.15, T_dp, p[0], r[0], theta[0], q_v[0]);


for (int k=1;k<=khi;k++){
z = prob_lo_z + (k+0.5)*dz;
p[k] = p[k-1];
compute_p_k(p[k], p[k-1], theta[k], r[k], q_v[k], T_dp, T_b, dz, z, r[k-1]);
//fprintf(file_IC, "%0.15g %0.15g %0.15g %0.15g %0.15g %0.15g %0.15g\n", z, T_b-273.15, T_dp, p[k], r[k], theta[k], q_v[k]);
}
//fclose(file_IC);


r[khi+1] = r[khi];
}
Expand All @@ -199,8 +187,6 @@ Problem::erf_init_dens_hse_moist (MultiFab& rho_hse,
std::unique_ptr<MultiFab>& z_phys_nd,
Geometry const& geom)
{


const Real prob_lo_z = geom.ProbLo()[2];
const Real dz = geom.CellSize()[2];
const int khi = geom.Domain().bigEnd()[2];
Expand Down Expand Up @@ -241,17 +227,11 @@ Problem::erf_init_dens_hse_moist (MultiFab& rho_hse,
Vector<Real> h_t(khi+2);
Vector<Real> h_q_v(khi+2);

amrex::Gpu::DeviceVector<Real> d_r(khi+2);
amrex::Gpu::DeviceVector<Real> d_p(khi+2);
amrex::Gpu::DeviceVector<Real> d_t(khi+2);
amrex::Gpu::DeviceVector<Real> d_q_v(khi+2);

init_isentropic_hse_no_terrain(h_t.data(), h_r.data(),h_p.data(), h_q_v.data(), dz,prob_lo_z,khi);

amrex::Gpu::DeviceVector<Real> d_r(khi+2);

amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_r.begin(), h_r.end(), d_r.begin());
amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_p.begin(), h_p.end(), d_p.begin());
amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_t.begin(), h_t.end(), d_t.begin());
amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_q_v.begin(), h_q_v.end(), d_q_v.begin());

Real* r = d_r.data();

Expand Down Expand Up @@ -355,18 +335,18 @@ Problem::init_custom_pert (
}

theta_total = t[k] + delta_theta;
temperature = compute_temperature(p[k], theta_total);
Real T_b = compute_temperature(p[k], t[k]);
temperature = getTgivenPandTh(theta_total, p[k], (R_d/Cp_d));
Real T_b = getTgivenPandTh(t[k] , p[k], (R_d/Cp_d));
RH = compute_relative_humidity(z, height, z_tr, p[k], T_b);
Real q_v_hot = vapor_mixing_ratio(z, height, p[k], T_b, RH);
rho = p[k]/(R_d*temperature*(1.0 + (R_v/R_d)*q_v_hot));

// Compute background quantities
Real temperature_back = compute_temperature(p[k], t[k]);
Real T_back = compute_temperature(p[k], t[k]);
Real temperature_back = getTgivenPandTh(t[k], p[k], (R_d/Cp_d));
Real T_back = getTgivenPandTh(t[k], p[k], (R_d/Cp_d));
Real RH_back = compute_relative_humidity(z, height, z_tr, p[k], T_back);
Real q_v_back = vapor_mixing_ratio(z, height, p[k], T_back, RH_back);
Real rho_back = p[k]/(R_d*temperature_back*(1.0 + (R_v/R_d)*q_v_back));
Real rho_back = getRhogivenTandPress(temperature_back, p[k], q_v_back);

// This version perturbs rho but not p
state_pert(i, j, k, RhoTheta_comp) = rho*theta_total - rho_back*t[k]*(1.0 + (R_v/R_d)*q_v_back);// rho*d_t[k]*(1.0 + R_v_by_R_d*q_v_hot);
Expand Down
Loading

0 comments on commit 72bf212

Please sign in to comment.