-
Notifications
You must be signed in to change notification settings - Fork 5
Implement a KinematicModel based on PrescribedVelocityFields #394
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
d90600f
KinematicModel based on PrescribedVelocityFields
glwagner 37ffad5
refactor
glwagner fef5e4a
cleaner implementation
glwagner f42faed
cleaner design
glwagner e60b296
fix
glwagner 7412ffe
fix show
glwagner 9453a0c
fix show
glwagner 117b735
fix filenames
glwagner d1faab5
fix filenames
glwagner c0e152c
better errror
glwagner 6eefe5b
fixes
glwagner c082155
fixes
glwagner 3d190c2
fix
glwagner 1a68967
rm stale imports
glwagner bcfc332
Merge branch 'main' into glw/kinematic-driver
glwagner ffb3fff
support velocity boundary conditions with PrescribedDynamics
glwagner cbe2404
revamp kinematic driver to support non-prescribed density, plus diver…
glwagner 04bc8db
Merge branch 'main' into glw/kinematic-driver
glwagner 85e8907
add a kinematic driver example, plus fcomputation of hydrostatic pres…
glwagner bfb8418
surface_density utility
glwagner 8d24f0b
fix tests
glwagner 8d1cf8b
fix
glwagner 35f50cb
bring back examples
glwagner e069e96
add adapt_structure for PrescribedDensity
glwagner ed78fdd
delete some code
glwagner af1126d
Add `Adapt` to test environment
giordano 2ccb1fb
Add missing method
giordano b304385
Update docs/make.jl
glwagner f34855d
Update docs/make.jl
glwagner c8d625e
Update docs/make.jl
glwagner c63cf5e
Update src/KinematicDriver/prescribed_dynamics.jl
glwagner ede602b
Merge branch 'main' into glw/kinematic-driver
giordano 2c77331
Update KinematicDriver.jl
giordano 98cec51
add kinematic driver to make.jl
glwagner 35d2ce5
export surface density
glwagner bc31766
rm reference to stationary parcel model
glwagner 8080d3d
Merge branch 'main' into glw/kinematic-driver
glwagner 6311e0b
Apply suggestion from @giordano
giordano 75d51b8
fix materialize dynamics
glwagner c2d1caf
fix constructor for AtmosphereModel
glwagner 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
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,42 @@ | ||
| """ | ||
| KinematicDriver | ||
|
|
||
| Module implementing kinematic dynamics for atmosphere models. | ||
|
|
||
| Kinematic dynamics prescribes the velocity field rather than solving for it, | ||
| enabling isolated testing of microphysics, thermodynamics, and other physics | ||
| without the complexity of solving the momentum equations. | ||
|
|
||
| This is analogous to the `kin1d` driver in P3-microphysics. | ||
| """ | ||
| module KinematicDriver | ||
|
|
||
| export | ||
| PrescribedDynamics, | ||
| KinematicModel | ||
|
|
||
| using DocStringExtensions: TYPEDSIGNATURES | ||
| using Adapt: Adapt, adapt | ||
|
|
||
| using Oceananigans: Oceananigans, CenterField, XFaceField, YFaceField, ZFaceField, fields | ||
| using Oceananigans.Architectures: architecture, on_architecture | ||
| using Oceananigans.BoundaryConditions: fill_halo_regions! | ||
| using Oceananigans.Fields: FunctionField, ZeroField, field | ||
| using Oceananigans.Grids: Face, Center | ||
| using Oceananigans.TimeSteppers: Clock, TimeSteppers | ||
| using Oceananigans.Utils: prettysummary | ||
|
|
||
| # Import PrescribedVelocityFields from Oceananigans | ||
| using Oceananigans.Models.HydrostaticFreeSurfaceModels: PrescribedVelocityFields | ||
|
|
||
| using Breeze.Thermodynamics: ReferenceState | ||
| using Breeze.AtmosphereModels: AtmosphereModels, AtmosphereModel | ||
|
|
||
| include("prescribed_dynamics.jl") | ||
|
|
||
| # Type alias for kinematic models | ||
| const KinematicModel = AtmosphereModel{<:PrescribedDynamics} | ||
|
|
||
| include("kinematic_driver_time_stepping.jl") | ||
|
|
||
| end # module |
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,44 @@ | ||
| ##### | ||
| ##### Time stepping for PrescribedDynamics (kinematic dynamics) | ||
| ##### | ||
|
|
||
| using Oceananigans.Fields: set!, FunctionField | ||
|
|
||
| ##### | ||
| ##### Model initialization | ||
| ##### | ||
|
|
||
| AtmosphereModels.initialize_model_thermodynamics!(m::KinematicModel) = set!(m, θ=m.dynamics.reference_state.potential_temperature) | ||
|
|
||
| ##### | ||
| ##### Velocity and momentum: no-ops (no momentum, velocities may be FunctionFields) | ||
| ##### | ||
|
|
||
| AtmosphereModels.compute_velocities!(::KinematicModel) = nothing | ||
| AtmosphereModels.compute_momentum_tendencies!(::KinematicModel, model_fields) = nothing | ||
|
|
||
| ##### | ||
| ##### Setting velocities for kinematic models | ||
| ##### | ||
|
|
||
| # Dispatch on velocity specification stored in dynamics | ||
| AtmosphereModels.set_velocity!(model::KinematicModel, name::Symbol, value) = | ||
| set_velocity!(model.dynamics.velocity_specification, model.velocities, name, value) | ||
|
|
||
| # Regular velocity fields (velocity_specification is nothing): just set directly | ||
| set_velocity!(::Nothing, velocities, name, value) = set!(velocities[name], value) | ||
|
|
||
| # PrescribedVelocityFields: cannot be set | ||
| set_velocity!(::PrescribedVelocityFields, velocities, name, value) = | ||
| throw(ArgumentError("Cannot set velocity component '$name' of PrescribedVelocityFields.")) | ||
|
|
||
| # No momentum in kinematic models | ||
| AtmosphereModels.set_momentum!(::KinematicModel, name::Symbol, value) = | ||
| throw(ArgumentError("Cannot set momentum component '$name' of a KinematicModel.")) | ||
|
|
||
| ##### | ||
| ##### Pressure correction: no-op for kinematic dynamics | ||
| ##### | ||
|
|
||
| TimeSteppers.compute_pressure_correction!(::KinematicModel, Δt) = nothing | ||
| TimeSteppers.make_pressure_correction!(::KinematicModel, Δt) = nothing |
Oops, something went wrong.
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.
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.
Can we set velocity as a function of time? I believe so, but I’m not certain.
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.
Yes! For time-dependent velocity fields, you need to build them explicitly in advance of the model with
PrescribedVelocityFieldsand then pass them into the model: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.
Initially I was thinking taht we wouldn't support
set!at all, but it is actually simply enough if the velocities are ordinaryField.For boundary conditinons, do you think that we should accept boundary conditions on the velocity field? eg something like
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 believe it should also be easy to have inlet boundary conditions with PrescribedVelocityFields (in that case no special thing is needed except defining functions w(z, t) that are non-zero at z=0)
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.
Looks good to me!