-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb939ff
commit 11a904d
Showing
4 changed files
with
253 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 41 additions & 28 deletions
69
include/tuvx/radiative_transfer/solvers/delta_eddington.inl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,56 @@ | ||
// Copyright (C) 2023-2024 National Center for Atmospheric Research | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace tuvx | ||
{ | ||
template<typename T, typename ArrayPolicy, typename RadiatorStatePolicy> | ||
void DeltaEddingtonApproximation( | ||
inline void EddingtonApproximation( | ||
const std::size_t& number_of_columns, | ||
const std::size_t& number_of_wavelengths, | ||
const std::size_t& number_of_layers, | ||
const RadiatorStatePolicy& accumulated_radiator_states, | ||
const std::map<std::string, std::vector<T>> solution_parameters, | ||
const std::vector<T> solar_zenith_angles) | ||
const std::vector<T>& solar_zenith_angles, | ||
ApproximationVariables<ArrayPolicy>& approximation_variables) | ||
{ | ||
// allocate memory for the approximation parameters | ||
approximation_variables.gamma1_ = tuvx::Array3D<double>(number_of_layers, number_of_wavelengths, number_of_columns); | ||
approximation_variables.gamma2_ = tuvx::Array3D<double>(number_of_layers, number_of_wavelengths, number_of_columns); | ||
approximation_variables.gamma3_ = tuvx::Array3D<double>(number_of_layers, number_of_wavelengths, number_of_columns); | ||
approximation_variables.gamma4_ = tuvx::Array3D<double>(number_of_layers, number_of_wavelengths, number_of_columns); | ||
approximation_variables.mu_ = tuvx::Array3D<double>(number_of_layers, number_of_wavelengths, number_of_columns); | ||
approximation_variables.lambda_ = tuvx::Array3D<double>(number_of_layers, number_of_wavelengths, number_of_columns); | ||
approximation_variables.gamma_ = tuvx::Array3D<double>(number_of_layers, number_of_wavelengths, number_of_columns); | ||
|
||
const std::size_t number_of_columns = solar_zenith_angles.size(); | ||
ArrayPolicy& omega = accumulated_radiator_states.optical_depth_; | ||
ArrayPolicy& g = accumulated_radiator_states.single_scattering_albedo_; | ||
ArrayPolicy& tau = accumulated_radiator_states.assymetry_parameter_; | ||
// unpack optical properties from radiator | ||
auto& omega = accumulated_radiator_states.optical_depth_; | ||
auto& g = accumulated_radiator_states.single_scattering_albedo_; | ||
auto& tau = accumulated_radiator_states.asymmetry_parameter_; | ||
|
||
// delta eddington parameters | ||
std::vector<T>& gamma1 = solution_parameters.at("gamma1"); | ||
std::vector<T>& gamma2 = solution_parameters.at("gamma2"); | ||
std::vector<T>& gamma3 = solution_parameters.at("gamma3"); | ||
std::vector<T>& gamma4 = solution_parameters.at("gamma4"); | ||
std::vector<T>& mu = solution_parameters.at("mu"); | ||
std::vector<T>& lambda = solution_parameters.at("lambda"); | ||
std::vector<T>& gamma = solution_parameters.at("Gamma"); | ||
// unpack delta eddington variables | ||
auto& gamma1 = approximation_variables.gamma1_; | ||
auto& gamma2 = approximation_variables.gamma2_; | ||
auto& gamma3 = approximation_variables.gamma3_; | ||
auto& gamma4 = approximation_variables.gamma4_; | ||
auto& lambda = approximation_variables.lambda_; | ||
auto& gamma = approximation_variables.gamma_; | ||
auto& mu = approximation_variables.mu_; | ||
|
||
// simulation parameters | ||
T mu_0; | ||
for (std::size_t i = 0; i < number_of_columns; i++) | ||
for (std::size_t i = 0; i < number_of_layers; i++) | ||
{ | ||
// compute delta eddington parameters | ||
mu_0 = std::acos(solar_zenith_angles[i]); | ||
gamma1[i] = 7 - omega[i] * (4 + 3 * g[i]); | ||
gamma2[i] = -(1 - omega[i] * (4 - 3 * g[i])) / 4; | ||
gamma3[i] = (2 - 3 * g[i] * mu_0) / 4; | ||
gamma4[i] = 1 - gamma3[i]; | ||
lambda[i] = std::sqrt(gamma1[i] * gamma1[i] - gamma2[i] * gamma2[i]); | ||
gamma[i] = (gamma1[i] - lambda[i]) / gamma2[i]; | ||
mu = (T)0.5; | ||
for (std::size_t j = 0; j < number_of_wavelengths; j++) | ||
{ | ||
for (std::size_t k = 0; k < number_of_columns; k++) | ||
{ | ||
mu_0 = std::acos(solar_zenith_angles[i]); | ||
gamma1(i, j, k) = 7 - omega(i, j, k) * (4 + 3 * g(i, j, k)); | ||
gamma2(i, j, k) = -(1 - omega(i, j, k) * (4 - 3 * g(i, j, k))) / 4; | ||
gamma3(i, j, k) = (2 - 3 * g(i, j, k) * mu_0) / 4; | ||
gamma4(i, j, k) = 1 - gamma3(i, j, k); | ||
lambda(i, j, k) = std::sqrt(gamma1(i, j, k) * gamma1(i, j, k) - gamma2(i, j, k) * gamma2(i, j, k)); | ||
gamma(i, j, k) = (gamma1(i, j, k) - lambda(i, j, k)) / gamma2(i, j, k); | ||
mu(i, j, k) = 0.5; | ||
} | ||
} | ||
} | ||
|
||
} | ||
} // namespace tuvx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.