-
Notifications
You must be signed in to change notification settings - Fork 5
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
Tr/add get fields atmos #1205
Tr/add get fields atmos #1205
Conversation
f2d41d5
to
0aed291
Compare
0aed291
to
328d9b0
Compare
854a22d
to
f7c38c9
Compare
else | ||
direct_flux_dn = radiation_model.face_sw_direct_flux_dn[1, :] | ||
FT = eltype(total_flux_dn) | ||
diffuse_fractions = (total_flux_dn .- direct_flux_dn) ./ (max.(total_flux_dn, eps(FT))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we want to limit it between 0 and 1 just to be exra safe. I don't think it should matter, maybe we can also wait and see if there is a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diffuse_fraction is now clamped to [0,1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
function Interfacer.update_field!(sim::ClimaAtmosSimulation, ::Val{:emissivity}, field) | ||
# sets all 16 bands (rows) to the same values | ||
sim.integrator.p.radiation.rrtmgp_model.surface_emissivity .= | ||
reshape(CC.Fields.field2array(field), 1, length(parent(field))) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the long term, maybe we can make the RRTMGPInterface assume every band is the same if only one value is passed in (maybe this is already the behavior not? I'm not sure). This way we don't need to hard code the length(parent) here.
We recently changed CO2 from being read in within ClimaCoupler and passed to ClimaAtmos, to being read in within ClimaAtmos. We should have removed the When we use the full land model, we'll need to read in mean global co2 from the atmosphere and pass it to the land model, so we need a |
@szy21 @Sbozzolo Will the field |
It is always filled. Here's how it's filled in the fixedco2 case |
What if co2 is set to
|
If it's nothing and you arent' using radiation, co2 is not set because rrtgmp is also not defined |
beb25cc
to
67d8d6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! We should update the docs too - could you add a section to the Interfacer.md docs ### AtmosModelSimulation - required functions to run with ClimaLandSimulation
that explains which get_field
and update_field!
methods are required to run with the full land (i.e. the ones you've added here). It would be good to note which ones won't be present if the atmosphere doesn't have radiation, and that because of this we need to enable radiation in the atmosphere when running with the full land model. Thank you!
f32cf97
to
11e4d33
Compare
Add diffuse_fraction, SW_d, LW_d, and cos of the zenith_angle to get_field on AtmosModelSimulation in Interfacer.jl. Add get_field methods for the above values in ClimaAtmosSimulation Remove safe_div and use anonymous func Only calculate on first level for diffuse_frac Add update_field for emissivity in AtmosModelSim Add emissivity to update_field in the Interfacer, and add a method definition for it in climaatmos.jl All 16 bands are set to the same values. Clamp diffuse_fraction to [0,1] Remove :co2 from atmos update_field :co2 is removed from the default AtmosModelSimulation update_field. The method definition is also removed for ClimaAtmosSimulation. Add atmos get_field for :co2 Add a default get_field for :co2 with AtmosModelSimulation, and a method definition for ClimaAtmosSimulation. Note that this returns a scalar. Add new fields to interfacer_tests Revert to returning zero when dividing by zero In get_field(::ClimaAtmosSimulation, ::Val{:diffuse_fraction}
11e4d33
to
dd322ff
Compare
docs/src/interfacer.md
Outdated
| Coupler name | Description | Units | | ||
|-------------------|-------------|-------| | ||
| `air_pressure` | boundary air pressure | Pa | | ||
| `air_temperature` | boundary air temperature | K | | ||
| `cos_zenith_angle` | cosine of the zenith angle | | | ||
| `co2` | global mean co2 | ppm | | ||
| `diffuse_fraction` | fraction of downwards shortwave flux that is direct | | | ||
| `humidity` | boundary humidity | kg kg^-1 | | ||
| `LW_d` | downwards longwave flux | W m^-2 | | ||
| `SW_d` | downwards shortwave flux | W m^-2 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these descriptions accurate? Do the pressure and temperature values need air_
prepended to them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look good! Prepending air_
is a good idea to distinguish from surface_
. Instead of "boundary air pressure/temp/humidity", I would write "air pressure/temp/humidity at the bottom of the atmosphere", to avoid any confusion between the boundary layer of the atmosphere vs boundary surface
dd322ff
to
f20ed1c
Compare
Add them to the the generic get_field for AtmosModelSimulations and specific methods for ClimaAtmosSimulations
f20ed1c
to
9caf01b
Compare
da3ca99
to
9caf01b
Compare
It is refered to as `cos_zenith` by atmos and `cos\thetas` by land. This unifies it with one of the models. [skip ci]
9caf01b
to
0077d3c
Compare
CC.Fields.array2field(sim.integrator.p.radiation.rrtmgp_model.face_lw_flux_dn, axes(sim.integrator.u.f)), | ||
CC.Utilities.half, | ||
) | ||
Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:humidity}) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call it specific_humidity
to be more accurate, but up to you.
docs/src/interfacer.md
Outdated
|
||
| Coupler name | Description | Units | | ||
|-------------------|-------------|-------| | ||
| `air_pressure` | air pressure at the bottom of the atmosphere | Pa | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `air_pressure` | air pressure at the bottom of the atmosphere | Pa | | |
| `air_pressure` | air pressure at the bottom cell center of the atmosphere | Pa | |
(and same for other bottom variables)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just had one comment about throwing errors if the get_field
s aren't extended, but this looks good other than that!
src/Interfacer.jl
Outdated
@@ -155,12 +155,20 @@ an atmosphere component model. | |||
get_field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should error if these get_field
s aren't implemented - e.g. if we want to couple a simpler/different atmosphere with the bucket, it doesn't need to extend all these methods required only for the full land model. I was going to suggest that we could give warnings if these aren't extended, but that will print a lot of warnings, so maybe the best thing to do is just remove these fields from here and expect users to read what's required to extend from the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this would only error if the get_field
is actually called for that value. So if we used some simple atmosphere with the bucket, it would not need to extend get_field
for all the methods listed here, because get_field(::SomeSimpleAtmos, ::Val{:cos_zenith})
would never be called. Is that correct?
I think it might still make sense to split the get_field(::AtmosModelSimulation)
default error into what is required for coupling with all land models, and just what is required for coupling with ClimaLand.
remove from interfacer tests
aee4e44
to
c8329ff
Compare
Purpose
Add get_field methods that are needed to couple with the full land model.
Also adds update_field for
emissivity
.Closes #1200
To-do
LHF/SHFContent
Add
air_pressure
,air_temperature
,humidity
,co2
,diffuse_fraction
,SW_d
,LW_d
, andcos_zenith_angle
to get_field on AtmosModelSimulation in Interfacer.jl.
Add get_field methods for the above values in
ClimaAtmosSimulation
Add
emissivity
to update_field on AtmosModelSimulation in Interfacer.jl,and add a method for it in ClimaAtmosSimulation
Remove
co2
from update_field on AtmosModelSimulation in Interfacer.jl andmethod definition for ClimaAtmosSimulation