-
Notifications
You must be signed in to change notification settings - Fork 5
Build abstraction for computing saturation vapor pressure over mixed phase surfaces #142
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 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5a9a323
Build abstraction for mixed phase surfaces
glwagner fc17007
add tests
glwagner eed1586
doctest
glwagner ba86b03
add zero
glwagner dc0dc66
update clausuis claperyon docs
glwagner e94e4df
Merge branch 'main' into glw/mixed-phase-saturation
navidcy f822fb4
Update src/Thermodynamics/vapor_saturation.jl
glwagner f78b433
Update src/Thermodynamics/vapor_saturation.jl
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| using Breeze | ||
| using Test | ||
|
|
||
| using Breeze.Thermodynamics: | ||
| ThermodynamicConstants, | ||
| saturation_vapor_pressure, | ||
| PlanarLiquidSurface, | ||
| PlanarIceSurface, | ||
| PlanarMixedPhaseSurface, | ||
| absolute_zero_latent_heat, | ||
| specific_heat_difference, | ||
| vapor_gas_constant | ||
|
|
||
| function reference_mixed_surface_pressure(T, thermo, λ) | ||
| ℒˡ₀ = absolute_zero_latent_heat(thermo, thermo.liquid) | ||
| ℒⁱ₀ = absolute_zero_latent_heat(thermo, thermo.ice) | ||
| Δcˡ = specific_heat_difference(thermo, thermo.liquid) | ||
| Δcⁱ = specific_heat_difference(thermo, thermo.ice) | ||
|
|
||
| ℒ₀ = λ * ℒˡ₀ + (one(λ) - λ) * ℒⁱ₀ | ||
| Δcᵝ = λ * Δcˡ + (one(λ) - λ) * Δcⁱ | ||
|
|
||
| Tᵗʳ = thermo.triple_point_temperature | ||
| pᵗʳ = thermo.triple_point_pressure | ||
| Rᵛ = vapor_gas_constant(thermo) | ||
|
|
||
| return pᵗʳ * (T / Tᵗʳ)^(Δcᵝ / Rᵛ) * exp((one(T) / Tᵗʳ - one(T) / T) * ℒ₀ / Rᵛ) | ||
| end | ||
|
|
||
| @testset "Saturation vapor pressure surfaces [$FT]" for FT in (Float32, Float64) | ||
| thermo = ThermodynamicConstants(FT) | ||
| Tᵗʳ = thermo.triple_point_temperature | ||
| temperatures = FT.((Tᵗʳ * FT(0.9), Tᵗʳ, Tᵗʳ * FT(1.1))) | ||
|
|
||
| liquid_surface = PlanarLiquidSurface() | ||
| ice_surface = PlanarIceSurface() | ||
| rtol = FT === Float64 ? 1e-12 : FT(1e-5) | ||
|
|
||
| @testset "Planar homogeneous surfaces" begin | ||
| for T in temperatures | ||
| pˡ = saturation_vapor_pressure(T, thermo, thermo.liquid) | ||
| pⁱ = saturation_vapor_pressure(T, thermo, thermo.ice) | ||
|
|
||
| @test saturation_vapor_pressure(T, thermo, liquid_surface) ≈ pˡ rtol=rtol | ||
| @test saturation_vapor_pressure(T, thermo, ice_surface) ≈ pⁱ rtol=rtol | ||
| end | ||
| end | ||
|
|
||
| @testset "Planar mixed-phase surfaces" begin | ||
| for λ in (zero(FT), FT(0.25), FT(0.5), FT(0.75), one(FT)) | ||
| surface = PlanarMixedPhaseSurface(λ) | ||
| for T in temperatures | ||
| p_surface = saturation_vapor_pressure(T, thermo, surface) | ||
| p_reference = reference_mixed_surface_pressure(T, thermo, λ) | ||
|
|
||
| @test p_surface ≈ p_reference rtol=rtol | ||
| end | ||
| end | ||
| end | ||
| end |
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.