Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/Whitespace.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this!

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Whitespace

permissions: {}

on:
push:
branches:
- 'main'
pull_request:

jobs:
whitespace:
name: Check whitespace
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout the NumericalEarth/Breeze.jl repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Checkout the JuliaLang/julia repository
uses: actions/checkout@v6
with:
persist-credentials: false
repository: 'JuliaLang/julia'
# Clone Julia in a subdir.
path: '.julia'
# Check out a fixed revision to avoid surprises in case the script is
# changed in the future.
ref: '3b12a882e887753e4d2e9e9db65d99d3f7d9e26b'
- uses: julia-actions/setup-julia@v2
with:
version: '1.12.4'
- name: Check whitespace
run: |
.julia/contrib/check-whitespace.jl
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ serve(dir="docs/build")
When implementing a simulation from a published paper:

### 1. Parameter Extraction
- **Read the paper carefully** and extract ALL parameters: domain size, resolution, physical constants,
- **Read the paper carefully** and extract ALL parameters: domain size, resolution, physical constants,
boundary conditions, initial conditions, forcing, closure parameters
- Look for parameter tables (often "Table 1" or similar)
- Check figure captions for additional details
Expand Down Expand Up @@ -433,11 +433,11 @@ Before running a long simulation:
- Quantitative comparison: compute the same diagnostics as the paper

### 7. Common Issues
- **NaN blowups**: Usually from timestep too large, unstable initial conditions,
- **NaN blowups**: Usually from timestep too large, unstable initial conditions,
or if-else statements on GPU (use `ifelse` instead)
- **Nothing happening**: Check that buoyancy anomaly has the right sign,
- **Nothing happening**: Check that buoyancy anomaly has the right sign,
that initial conditions are actually applied, that forcing is active
- **Wrong direction of flow**: Check coordinate conventions (is y increasing
- **Wrong direction of flow**: Check coordinate conventions (is y increasing
upslope or downslope?)
- **GPU issues**: Avoid branching, ensure type stability, use `randn()` carefully

Expand Down
2 changes: 1 addition & 1 deletion docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ See [`ExplicitImports.jl` documentation](https://juliatesting.github.io/Explicit
## Building the documentation locally

`Breeze.jl` [documentation](https://numericalearth.github.io/BreezeDocumentation/) is generated using [`Documenter.jl`](https://github.com/JuliaDocs/Documenter.jl).
You can preview how the documentation will look like with your changes by building the documentation locally.
You can preview how the documentation will look like with your changes by building the documentation locally.
From the top-level directory of your local repository run

```sh
Expand Down
6 changes: 3 additions & 3 deletions docs/src/developer/microphysics_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ a microphysics implementation in `AtmosphereModel`:

## Example implementation

To illustrate the development of a new microphysics scheme, we implement a
To illustrate the development of a new microphysics scheme, we implement a
simple microphysics scheme that represents droplet and ice particle nucleation
with constant-rate relaxation of specific humidity to saturation.

Expand All @@ -59,7 +59,7 @@ prognostic_field_names(::ExplicitMicrophysics) = (:ρqᵛ, :ρqˡ, :ρqⁱ)
```

!!! note
The names of prognostic fields defined by `prognostic_field_names`
The names of prognostic fields defined by `prognostic_field_names`
**are crucial to the user interface**, because users can interact them and
[`set!`](https://clima.github.io/OceananigansDocumentation/stable/appendix/library/#Oceananigans.Fields.set!) their initial conditions. The names of variables should be carefully
chosen to be concise, mathematical forms that are consistent with Breeze conventions.
Expand All @@ -78,7 +78,7 @@ function materialize_microphysical_fields(::ExplicitMicrophysics, grid, boundary
return (; ρqˡ, ρqⁱ, ρqᵛ, qᵛ)
end
```
The tendencies for
The tendencies for

```@example microphysics_interface
import Breeze.AtmosphereModels: microphysical_tendency
Expand Down
2 changes: 1 addition & 1 deletion examples/boussinesq_bomex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ set!(Fθ_field, z -> dTdt_bomex(1, z))
θ_forcing = (θ_radiation_forcing, θ_subsidence_forcing)

model = NonhydrostaticModel(; grid, buoyancy, coriolis,
advection = WENO(order=5),
advection = WENO(order=5),
tracers = (:θ, :qᵗ),
forcing = (; qᵗ=qᵗ_forcing, u=u_forcing, v=v_forcing, θ=θ_forcing),
boundary_conditions = (θ=θ_bcs, qᵗ=qᵗ_bcs, u=u_bcs, v=v_bcs))
Expand Down
2 changes: 1 addition & 1 deletion examples/cloudy_thermal_bubble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ nothing #hide
# following the methodology described by Bryan and Fritsch (2002). This simulation
# includes moisture processes, where excess water vapor condenses to liquid water,
# releasing latent heat that enhances the buoyancy of the rising bubble.
#
#
# For pedagogical purposes, we build a new model with warm-phase saturation adjustment microphysics.
# (We coudl have also used this model for the dry simulation):

Expand Down
4 changes: 2 additions & 2 deletions examples/prescribed_sea_surface_temperature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ Uᵍ = 1e-2 # Minimum wind speed (m/s)
#
# For `BulkVaporFlux`, the saturation specific humidity is computed from the surface
# temperature. Surface temperature can be provided as a `Field`, a `Function`, or a `Number`.
#
#
# In this example, we specify the sea surface temperature as a top hat function
# i.e. representing a pair of ocean fronts in a periodic domain, with a
# i.e. representing a pair of ocean fronts in a periodic domain, with a
# difference of 4 degrees K,

ΔT = 4 # K
Expand Down
2 changes: 1 addition & 1 deletion examples/rico.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ set!(∂t_ρqᵗ_large_scale, ρᵣ * ∂t_ρqᵗ_large_scale)
# This is the key simplification that allows us to avoid interactive radiation.

∂t_ρθ_large_scale = Field{Nothing, Nothing, Center}(grid)
∂t_θ_large_scale = - 2.5 / day # K / day
∂t_θ_large_scale = - 2.5 / day # K / day
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaced

julia> ' '
' ': Unicode U+00A0 (category Zs: Separator, space)

with

julia> ' '
' ': ASCII/Unicode U+0020 (category Zs: Separator, space)

No idea how a non-breaking space ended up there in the first place.

set!(∂t_ρθ_large_scale, ρᵣ * ∂t_θ_large_scale)
ρθ_large_scale_forcing = Forcing(∂t_ρθ_large_scale)

Expand Down
2 changes: 1 addition & 1 deletion ext/BreezeCloudMicrophysicsExt/one_moment_helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Adapt.adapt_structure(to, k::SurfacePrecipitationFluxKernel) =
# wʳ < 0 (downward), so -wʳ * ρqʳ > 0 represents flux out of domain
@inbounds wʳ = kernel.terminal_velocity[i, j, 1]
@inbounds ρqʳ = kernel.rain_density[i, j, 1]

# Return positive flux for rain leaving domain (downward)
return -wʳ * ρqʳ
end
Expand Down
1 change: 0 additions & 1 deletion ext/BreezeCloudMicrophysicsExt/two_moment_helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,3 @@ function Base.show(io::IO, bμp::BulkMicrophysics{<:Any, <:CM2MCategories})
end

Base.summary(bμp::TwoMomentCloudMicrophysics) = "TwoMomentCloudMicrophysics"

3 changes: 1 addition & 2 deletions ext/BreezeRRTMGPExt/BreezeRRTMGPExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using Oceananigans.Fields: ZFaceField

# RRTMGP imports (external types - cannot modify)
# GrayAtmosphericState: atmospheric state arrays (t_lay, p_lay, t_lev, p_lev, z_lev, t_sfc)
# NoScatLWRTE, NoScatSWRTE: longwave/shortwave RTE solvers
# NoScatLWRTE, NoScatSWRTE: longwave/shortwave RTE solvers
# FluxLW, FluxSW: flux storage (flux_up, flux_dn, flux_net, flux_dn_dir)
# RRTMGPParameters: physical constants for RRTMGP

Expand Down Expand Up @@ -76,4 +76,3 @@ include("clear_sky_radiative_transfer_model.jl")
include("all_sky_radiative_transfer_model.jl")

end # module

2 changes: 1 addition & 1 deletion ext/BreezeRRTMGPExt/all_sky_radiative_transfer_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ RRTMGP loads lookup tables from netCDF via an extension.
# Keyword Arguments
- `background_atmosphere`: Background atmospheric gas composition (default: `BackgroundAtmosphere{FT}()`).
- `surface_temperature`: Surface temperature in Kelvin (required).
- `coordinate`: Tuple of (longitude, latitude) in degrees. If `nothing` (default),
- `coordinate`: Tuple of (longitude, latitude) in degrees. If `nothing` (default),
extracted from grid coordinates.
- `epoch`: Optional epoch for computing time with floating-point clocks.
- `surface_emissivity`: Surface emissivity, 0-1 (default: 0.98). Scalar.
Expand Down
2 changes: 1 addition & 1 deletion ext/BreezeRRTMGPExt/clear_sky_radiative_transfer_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RRTMGP loads lookup tables from netCDF via an extension.
# Keyword Arguments
- `background_atmosphere`: Background atmospheric gas composition (default: `BackgroundAtmosphere{FT}()`).
- `surface_temperature`: Surface temperature in Kelvin (required).
- `coordinate`: Tuple of (longitude, latitude) in degrees. If `nothing` (default),
- `coordinate`: Tuple of (longitude, latitude) in degrees. If `nothing` (default),
extracted from grid coordinates.
- `epoch`: Optional epoch for computing time with floating-point clocks.
- `surface_emissivity`: Surface emissivity, 0-1 (default: 0.98). Scalar.
Expand Down
4 changes: 2 additions & 2 deletions ext/BreezeRRTMGPExt/gray_radiative_transfer_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ Construct a gray atmosphere radiative transfer model for the given grid.
# Keyword Arguments
- `optical_thickness`: Optical thickness parameterization (default: `GrayOpticalThicknessOGorman2008(FT)`).
- `surface_temperature`: Surface temperature in Kelvin (required).
- `coordinate`: Tuple of (longitude, latitude) in degrees. If `nothing` (default),
- `coordinate`: Tuple of (longitude, latitude) in degrees. If `nothing` (default),
extracted from grid coordinates.
- `epoch`: Optional epoch for computing time with floating-point clocks.
- `surface_emissivity`: Surface emissivity, 0-1 (default: 0.98). Scalar.
- `surface_albedo`: Surface albedo, 0-1. Can be scalar or 2D field.
- `surface_albedo`: Surface albedo, 0-1. Can be scalar or 2D field.
Alternatively, provide both `direct_surface_albedo` and `diffuse_surface_albedo`.
- `direct_surface_albedo`: Direct surface albedo, 0-1. Can be scalar or 2D field.
- `diffuse_surface_albedo`: Diffuse surface albedo, 0-1. Can be scalar or 2D field.
Expand Down
1 change: 0 additions & 1 deletion ext/BreezeRRTMGPExt/rrtmgp_shared_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,3 @@ end
ℐ_sw_dn[i, j, k] = -sw_flux_dn[k, col]
end
end

1 change: 0 additions & 1 deletion src/AnelasticEquations/AnelasticEquations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ const AnelasticModel = AtmosphereModel{<:AnelasticDynamics}
include("anelastic_time_stepping.jl")

end # module

1 change: 0 additions & 1 deletion src/AnelasticEquations/anelastic_buoyancy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ where `pᵣ` is the reference pressure, `Rᵐ` is the mixture gas constant, and

return - g * ρ′
end

1 change: 0 additions & 1 deletion src/AnelasticEquations/anelastic_dynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,3 @@ function AtmosphereModels.materialize_momentum_and_velocities(dynamics::Anelasti

return momentum, velocities
end

1 change: 0 additions & 1 deletion src/AnelasticEquations/anelastic_pressure_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,3 @@ end
δ = divᶜᶜᶜ(i, j, k, grid, ρu, ρv, ρw)
@inbounds rhs[i, j, k] = active * Δzᶜᶜᶜ(i, j, k, grid) * δ / Δt
end

1 change: 0 additions & 1 deletion src/AnelasticEquations/anelastic_time_stepping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@ function TimeSteppers.make_pressure_correction!(model::AnelasticModel, Δt)

return nothing
end

Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,3 @@ end

const SaturationSpecificHumidityField = Field{C, C, C, <:SaturationSpecificHumidity}
SaturationSpecificHumidityField(model, flavor_symbol=:prognostic) = Field(SaturationSpecificHumidity(model, flavor_symbol))

1 change: 0 additions & 1 deletion src/AtmosphereModels/Diagnostics/static_energy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,3 @@ function (d::StaticEnergyKernelFunction)(i, j, k, grid)
return ρᵣ * e
end
end

2 changes: 1 addition & 1 deletion src/AtmosphereModels/dynamics_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function validate_velocity_boundary_conditions(dynamics, user_boundary_condition
velocity_names = (:u, :v, :w)
user_bc_names = keys(user_boundary_conditions)
provided_velocity_bcs = filter(name -> name ∈ user_bc_names, velocity_names)

if !isempty(provided_velocity_bcs)
throw(ArgumentError(
"Boundary conditions for velocity components $(provided_velocity_bcs) are not supported " *
Expand Down
2 changes: 1 addition & 1 deletion src/Breeze.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export
mixture_heat_capacity,
dynamics_density,
dynamics_pressure,

# Diagnostics
compute_hydrostatic_pressure!,
PotentialTemperature,
Expand Down
1 change: 0 additions & 1 deletion src/CompressibleEquations/compressible_buoyancy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ in the momentum equation without subtraction of a reference state.

return -g * ρ
end

1 change: 0 additions & 1 deletion src/CompressibleEquations/compressible_dynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,3 @@ function AtmosphereModels.materialize_momentum_and_velocities(dynamics::Compress

return momentum, velocities
end

1 change: 0 additions & 1 deletion src/CompressibleEquations/compressible_time_stepping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,3 @@ end

return T, p
end

2 changes: 1 addition & 1 deletion src/Forcings/subsidence_forcing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ end
# Strip the ρ prefix from density variable names
# e.g., :ρu → :u, :ρθ → :θ, :ρe → :e
function strip_density_prefix(name::Symbol)
chars = string(name) |> collect
chars = string(name) |> collect
prefix = popfirst!(chars)
return Symbol(chars...)
end
Expand Down
4 changes: 2 additions & 2 deletions src/KinematicDriver/kinematic_driver_time_stepping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ AtmosphereModels.set_velocity!(model::KinematicModel, name::Symbol, value) =
set_velocity!(velocity::AbstractField, value) = set!(velocity, value)

# FunctionFields (from PrescribedVelocityFields): cannot be set
set_velocity!(::FunctionField, value) =
set_velocity!(::FunctionField, value) =
throw(ArgumentError("Cannot set velocity component of PrescribedVelocityFields."))

# No momentum in kinematic models
AtmosphereModels.set_momentum!(::KinematicModel, name::Symbol, value) =
AtmosphereModels.set_momentum!(::KinematicModel, name::Symbol, value) =
throw(ArgumentError("Cannot set momentum component '$name' of a KinematicModel."))

#####
Expand Down
4 changes: 2 additions & 2 deletions src/Microphysics/dcmip2016_kessler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ end

# Temperature offset for saturation adjustment (from TetensFormula)
δT = constants.saturation_vapor_pressure.liquid_temperature_offset

# Microphysics parameters
cfl = microphysics.substep_cfl
Cᵨ = microphysics.density_scale
Expand Down Expand Up @@ -448,7 +448,7 @@ end
qˡ_sum = qᶜˡ + qʳ
qᵗ = max(qᵗ, qˡ_sum)
qᵛ = qᵗ - qˡ_sum

# Convert to mixing ratios for Kessler physics
q = MoistureMassFractions(qᵛ, qˡ_sum)
r = MoistureMixingRatio(q)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,3 @@ function Base.show(io::IO, formulation::LiquidIcePotentialTemperatureFormulation
print(io, "└── potential_temperature: ", prettysummary(formulation.potential_temperature))
end
end

1 change: 0 additions & 1 deletion src/StaticEnergyFormulations/static_energy_formulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,3 @@ function Base.show(io::IO, formulation::StaticEnergyFormulation)
print(io, "└── specific_energy: ", prettysummary(formulation.specific_energy))
end
end

4 changes: 2 additions & 2 deletions src/Thermodynamics/dynamic_states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end
qˡ = q.liquid
qⁱ = q.ice

return Π * θ + (ℒˡᵣ * qˡ + ℒⁱᵣ * qⁱ) / cᵖᵐ
return Π * θ + (ℒˡᵣ * qˡ + ℒⁱᵣ * qⁱ) / cᵖᵐ
end

@inline function with_temperature(𝒰::LiquidIcePotentialTemperatureState, T, constants)
Expand Down Expand Up @@ -125,4 +125,4 @@ end
e = cᵖᵐ * T + g * z - ℒˡᵣ * qˡ - ℒⁱᵣ * qⁱ

return StaticEnergyState(e, q, z, 𝒰.reference_pressure)
end
end
3 changes: 1 addition & 2 deletions src/Thermodynamics/thermodynamics_constants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ end

#####
##### Moisture mixing ratios
#####
#####

struct MoistureMixingRatio{FT}
vapor :: FT
Expand Down Expand Up @@ -517,4 +517,3 @@ Converts mixing ratios to mass fractions and calls `mixture_heat_capacity(q::MMF
@inline function mixture_heat_capacity(r::MR, constants::TC)
return mixture_heat_capacity(MoistureMassFractions(r), constants)
end

2 changes: 1 addition & 1 deletion src/Thermodynamics/vapor_saturation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Compute the supersaturation ``𝒮 = pᵛ/pᵛ⁺ - 1`` over a given `surface`.

# Arguments
- `T`: Temperature
- `ρ`: Total air density
- `ρ`: Total air density
- `q`: `MoistureMassFractions` containing vapor, liquid, and ice mass fractions
- `constants`: `ThermodynamicConstants`
- `surface`: Surface type (e.g., `PlanarLiquidSurface()`, `PlanarIceSurface()`)
Expand Down
3 changes: 1 addition & 2 deletions test/advection_schemes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using Test
@testset "Default advection schemes" begin
static_energy_model = AtmosphereModel(grid; thermodynamic_constants=constants, dynamics,
formulation=:StaticEnergy)
potential_temperature_model = AtmosphereModel(grid; thermodynamic_constants=constants, dynamics,
potential_temperature_model = AtmosphereModel(grid; thermodynamic_constants=constants, dynamics,
formulation=:LiquidIcePotentialTemperature)

@test static_energy_model.advection.ρe isa Centered
Expand Down Expand Up @@ -119,4 +119,3 @@ using Test
end
end
end

1 change: 0 additions & 1 deletion test/all_sky_radiative_transfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,3 @@ using RRTMGP
@test all(isfinite, interior(radiation.upwelling_longwave_flux))
end
end

1 change: 0 additions & 1 deletion test/atmosphere_model_construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ end
@test model.clock.iteration == 1
end
end

Loading