-
Notifications
You must be signed in to change notification settings - Fork 0
Add 12 hydrometeor variable recipes and 3 humidity recipes with TL/AD using diagnostic cloud scheme #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
38
commits into
develop
Choose a base branch
from
copilot/add-hydrometeor-variables-recipes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add 12 hydrometeor variable recipes and 3 humidity recipes with TL/AD using diagnostic cloud scheme #1
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
6d52433
Initial plan
Copilot ba47578
Add 12 hydrometeor variable recipes with diagnostic cloud scheme
Copilot 0005b8d
Rename effective radius variables to match ESM standard names
Copilot 37133bc
Apply code review feedback: update copyright, add Parameters classes,…
Copilot 75aae0e
Use air_pressure_thickness for more accurate mass content calculations
Copilot 69fff83
Update recipes from Smith 1990 to IFS/ERA5 parameterizations
Copilot 2e51e2f
Enforce 100-character line length limit across all recipe files
Copilot 58f505d
Update documentation style: move scientific references to headers, si…
Copilot 335a328
Update documentation to clarify simplified diagnostic approximations
Copilot 880dd09
Refine documentation format: add Martin et al. citation to relationsh…
Copilot f4ed6c9
Fix variable naming and remove unused code in precipitation recipes
Copilot 6b086cf
Add TotalRelativeHumidity_B recipe using water_vapor_mixing_ratio_wrt…
Copilot ccc7338
Replace TotalRelativeHumidity_B with RelativeHumidity_B recipe
Copilot 8ce5d17
Add TL/AD implementation for RelativeHumidity_B recipe
Copilot 13da03c
Add SaturationVaporPressure_B and SaturationSpecificHumidity_B with T…
Copilot 765710b
Clean up documentation and simplify variable names per review feedback
Copilot a7510c2
Replace Wexler (1976) with Murphy & Koop (2005) for saturation vapor …
Copilot b711fe8
Update variable naming and Parameters class per review feedback
Copilot 54659c6
Extend SaturationVaporPressure_B to handle saturation over ice
Copilot 1ca9701
Update recipes for separation of concerns and use model epsilon
Copilot 915b8dc
Fix variable naming and method signatures per review feedback
Copilot 4160c19
Fix RelativeHumidity_B method signatures to use void instead of bool
Copilot ec32566
Fix SaturationSpecificHumidity_B and SaturationVaporPressure_B per re…
Copilot 3faf484
Remove trailing whitespace from humidity recipe files
Copilot 9be0399
Fix variable name in SaturationSpecificHumidity_B trajectoryVars and …
Copilot 8ac9492
Fix surface pressure array indexing in all hydrometeor mass content r…
Copilot 1f76595
Change hasTLAD() to inline format and remove standalone implementations
Copilot 5bb88dc
adjusting whitespaces
fabiolrdiniz 793584a
adding a few more recipes
fabiolrdiniz efcce9f
missing files
fabiolrdiniz 302edae
Align newly added recipes with coding standards (Part 1)
Copilot 7301e6d
Standardize formatting across all newly added recipes (Part 3)
Copilot 2edcf50
Remove extra comments from variable declarations in SaturationSpecifi…
Copilot a47a534
Standardize adjoint zeroing comments across all recipes
Copilot 5367bd3
Fix missing \brief tags in documentation comments
Copilot d4ace25
Comprehensive code standardization across all recipes (Part 1)
Copilot 58fa3b4
Comprehensive code standardization across all recipes (Part 2)
Copilot 7380b4b
Fix indentation to 2-space standard in all .cc files
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * (C) Copyright 2025 UCAR | ||
| * | ||
| * This software is licensed under the terms of the Apache Licence Version 2.0 | ||
| * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "atlas/field/FieldSet.h" | ||
| #include "atlas/functionspace/FunctionSpace.h" | ||
| #include "oops/util/parameters/Parameter.h" | ||
| #include "oops/util/parameters/RequiredParameter.h" | ||
| #include "vader/RecipeBase.h" | ||
|
|
||
| namespace vader | ||
| { | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
|
|
||
| class EffectiveRadiusOfCloudIceParticle_AParameters : public RecipeParametersBase { | ||
| OOPS_CONCRETE_PARAMETERS(EffectiveRadiusOfCloudIceParticle_AParameters, | ||
| RecipeParametersBase) | ||
|
|
||
| public: | ||
| oops::RequiredParameter<std::string> name{"recipe name", this}; | ||
| }; | ||
|
|
||
| /*! \brief The class 'EffectiveRadiusOfCloudIceParticle_A' defines a recipe for | ||
| * effective radius of ice particle | ||
| * | ||
| * \details This instantiation of RecipeBase produces effective radius | ||
| * using a simplified diagnostic approximation with temperature-dependent | ||
| * relationship, based on Martin et al. (1994, J. Atmos. Sci., 51, 1823-1842) | ||
| * Inputs: air_temperature | ||
| * Output units: m | ||
| */ | ||
| class EffectiveRadiusOfCloudIceParticle_A : public RecipeBase | ||
| { | ||
| public: | ||
| static const char Name[]; | ||
| static const oops::Variables Ingredients; | ||
|
|
||
| typedef EffectiveRadiusOfCloudIceParticle_AParameters Parameters_; | ||
|
|
||
| EffectiveRadiusOfCloudIceParticle_A(const Parameters_ &, const VaderConfigVars &); | ||
|
|
||
| std::string name() const override; | ||
| oops::Variable product() const override; | ||
| oops::Variables ingredients() const override; | ||
| size_t productLevels(const atlas::FieldSet &) const override; | ||
| atlas::FunctionSpace productFunctionSpace(const atlas::FieldSet &) const override; | ||
|
|
||
| void executeNL(atlas::FieldSet &) override; | ||
fabiolrdiniz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private: | ||
| const VaderConfigVars & configVariables_; | ||
| }; | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
|
|
||
| } // namespace vader | ||
104 changes: 104 additions & 0 deletions
104
src/vader/recipes/EffectiveRadiusOfCloudIceParticle_A.cc
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * (C) Copyright 2025 UCAR | ||
| * | ||
| * This software is licensed under the terms of the Apache Licence Version 2.0 | ||
| * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
| */ | ||
|
|
||
| #include <cmath> | ||
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| #include "atlas/array.h" | ||
| #include "atlas/field/Field.h" | ||
| #include "oops/util/Logger.h" | ||
| #include "vader/recipes/EffectiveRadiusOfCloudIceParticle.h" | ||
|
|
||
| namespace vader { | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
| // Static attribute initialization | ||
| const char EffectiveRadiusOfCloudIceParticle_A::Name[] = | ||
| "EffectiveRadiusOfCloudIceParticle_A"; | ||
| const oops::Variables EffectiveRadiusOfCloudIceParticle_A::Ingredients{ | ||
| std::vector<std::string>{"air_temperature"}}; | ||
|
|
||
| // Register the maker | ||
| static RecipeMaker<EffectiveRadiusOfCloudIceParticle_A> | ||
| makerEffectiveRadiusOfCloudIceParticle_A_( | ||
| EffectiveRadiusOfCloudIceParticle_A::Name); | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
|
|
||
| EffectiveRadiusOfCloudIceParticle_A::EffectiveRadiusOfCloudIceParticle_A( | ||
| const Parameters_ & params, const VaderConfigVars & configVariables): | ||
| configVariables_{configVariables} { | ||
| oops::Log::trace() << "EffectiveRadiusOfCloudIceParticle_A::" | ||
| << "EffectiveRadiusOfCloudIceParticle_A" << std::endl; | ||
| } | ||
|
|
||
| std::string EffectiveRadiusOfCloudIceParticle_A::name() const { | ||
| return EffectiveRadiusOfCloudIceParticle_A::Name; | ||
| } | ||
|
|
||
| oops::Variable EffectiveRadiusOfCloudIceParticle_A::product() const { | ||
| return oops::Variable{"effective_radius_of_cloud_ice_particle"}; | ||
| } | ||
|
|
||
| oops::Variables EffectiveRadiusOfCloudIceParticle_A::ingredients() const { | ||
| return EffectiveRadiusOfCloudIceParticle_A::Ingredients; | ||
| } | ||
|
|
||
| size_t EffectiveRadiusOfCloudIceParticle_A::productLevels( | ||
| const atlas::FieldSet & afieldset) const { | ||
| return afieldset.field("air_temperature").shape(1); | ||
| } | ||
|
|
||
| atlas::FunctionSpace EffectiveRadiusOfCloudIceParticle_A::productFunctionSpace( | ||
| const atlas::FieldSet & afieldset) const { | ||
| return afieldset.field("air_temperature").functionspace(); | ||
| } | ||
|
|
||
| void EffectiveRadiusOfCloudIceParticle_A::executeNL(atlas::FieldSet & afieldset) { | ||
| oops::Log::trace() << "EffectiveRadiusOfCloudIceParticle_A::executeNL starting" | ||
| << std::endl; | ||
|
|
||
| // Get input field | ||
| auto temp = atlas::array::make_view<double, 2>(afieldset.field("air_temperature")); | ||
|
|
||
| // Create output field | ||
| auto reff_field = afieldset.field("effective_radius_of_cloud_ice_particle"); | ||
| auto reff = atlas::array::make_view<double, 2>(reff_field); | ||
|
|
||
| const size_t npoints = temp.shape(0); | ||
| const size_t nlevels = temp.shape(1); | ||
|
|
||
| // Temperature-dependent effective radius for ice particles | ||
| // Typical range: 20-100 micrometers | ||
| // Colder temperatures -> smaller crystals | ||
| const double T_freeze = 273.15; // K | ||
| const double T_cold = 233.15; // -40C | ||
| const double r_min = 20.0e-6; // minimum radius (m) | ||
| const double r_max = 100.0e-6; // maximum radius (m) | ||
|
|
||
| for (size_t jn = 0; jn < npoints; ++jn) { | ||
| for (size_t jl = 0; jl < nlevels; ++jl) { | ||
| const double T = temp(jn, jl); | ||
|
|
||
| if (T < T_freeze) { | ||
| // Warmer ice clouds have larger particles due to aggregation | ||
| const double temp_factor = (T - T_cold) / (T_freeze - T_cold); | ||
| reff(jn, jl) = r_min + (r_max - r_min) * std::max(0.0, std::min(1.0, temp_factor)); | ||
| } else { | ||
| // Above freezing, use minimum value | ||
| reff(jn, jl) = r_min; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| oops::Log::trace() << "EffectiveRadiusOfCloudIceParticle_A::executeNL done" << std::endl; | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
|
|
||
| } // namespace vader |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.