From fa1172865d0068d67b22a432f8ba8527308cb9ba Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Sat, 17 Aug 2024 18:44:07 +0200 Subject: [PATCH] more format fixes --- examples/elixir_moist_euler_EC_bubble.jl | 23 ++++++++++---------- examples/elixir_moist_euler_moist_bubble.jl | 24 ++++++++++----------- test/test_2d_moist_euler.jl | 2 +- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/examples/elixir_moist_euler_EC_bubble.jl b/examples/elixir_moist_euler_EC_bubble.jl index 745fa15..5b2f109 100644 --- a/examples/elixir_moist_euler_EC_bubble.jl +++ b/examples/elixir_moist_euler_EC_bubble.jl @@ -45,27 +45,28 @@ function generate_function_of_y(dz, y0, r_t0, theta_e0, return moist_state(y, dz, y0, r_t0, theta_e0, equations) end end + #Create Initial atmosphere by generating a layer data set struct AtmosphereLayers{RealT <: Real} equations::CompressibleMoistEulerEquations2D # structure: 1--> i-layer (z = total_height/precision *(i-1)), 2--> rho, rho_theta, rho_qv, rho_ql - LayerData::Matrix{RealT} # Contains the layer data for each height + layer_data::Matrix{RealT} # Contains the layer data for each height total_height::RealT # Total height of the atmosphere preciseness::Int # Space between each layer data (dz) layers::Int # Amount of layers (total height / dz) ground_state::NTuple{2, RealT} # (rho_0, p_tilde_0) to define the initial values at height z=0 - equivalentpotential_temperature::RealT # Value for theta_e since we have a constant temperature theta_e0=theta_e. + equivalent_potential_temperature::RealT # Value for theta_e since we have a constant temperature theta_e0=theta_e. mixing_ratios::NTuple{2, RealT} # Constant mixing ratio. Also defines initial guess for rho_qv0 = r_v0 * rho_0. end function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, ground_state = (1.4, 100000.0), - equivalentpotential_temperature = 320, + equivalent_potential_temperature = 320, mixing_ratios = (0.02, 0.02), RealT = Float64) @unpack kappa, p_0, c_pd, c_vd, c_pv, c_vv, R_d, R_v, c_pl = equations rho0, p0 = ground_state r_t0, r_v0 = mixing_ratios - theta_e0 = equivalentpotential_temperature + theta_e0 = equivalent_potential_temperature rho_qv0 = rho0 * r_v0 T0 = theta_e0 @@ -73,7 +74,7 @@ function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, n = convert(Int, total_height / preciseness) dz = 0.01 - LayerData = zeros(RealT, n + 1, 4) + layer_data = zeros(RealT, n + 1, 4) F = generate_function_of_y(dz, y0, r_t0, theta_e0, equations) sol = nlsolve(F, y0) @@ -84,7 +85,7 @@ function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, kappa_M = (R_d * rho_d + R_v * rho_qv) / (c_pd * rho_d + c_pv * rho_qv + c_pl * rho_ql) rho_theta = rho * (p0 / p)^kappa_M * T * (1 + (R_v / R_d) * r_v) / (1 + r_t) - LayerData[1, :] = [rho, rho_theta, rho_qv, rho_ql] + layer_data[1, :] = [rho, rho_theta, rho_qv, rho_ql] for i in (1:n) y0 = deepcopy(sol.zero) dz = preciseness @@ -98,17 +99,17 @@ function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, (c_pd * rho_d + c_pv * rho_qv + c_pl * rho_ql) rho_theta = rho * (p0 / p)^kappa_M * T * (1 + (R_v / R_d) * r_v) / (1 + r_t) - LayerData[i + 1, :] = [rho, rho_theta, rho_qv, rho_ql] + layer_data[i + 1, :] = [rho, rho_theta, rho_qv, rho_ql] end - return AtmosphereLayers{RealT}(equations, LayerData, total_height, dz, n, ground_state, + return AtmosphereLayers{RealT}(equations, layer_data, total_height, dz, n, ground_state, theta_e0, mixing_ratios) end # Generate background state from the Layer data set by linearely interpolating the layers function initial_condition_moist_bubble(x, t, equations::CompressibleMoistEulerEquations2D, atmosphere_layers::AtmosphereLayers) - @unpack LayerData, preciseness, total_height = atmosphere_layers + @unpack layer_data, preciseness, total_height = atmosphere_layers dz = preciseness z = x[2] if (z > total_height && !(isapprox(z, total_height))) @@ -116,13 +117,13 @@ function initial_condition_moist_bubble(x, t, equations::CompressibleMoistEulerE end n = convert(Int, floor(z / dz)) + 1 z_l = (n - 1) * dz - (rho_l, rho_theta_l, rho_qv_l, rho_ql_l) = LayerData[n, :] + (rho_l, rho_theta_l, rho_qv_l, rho_ql_l) = layer_data[n, :] z_r = n * dz if (z_l == total_height) z_r = z_l + dz n = n - 1 end - (rho_r, rho_theta_r, rho_qv_r, rho_ql_r) = LayerData[n + 1, :] + (rho_r, rho_theta_r, rho_qv_r, rho_ql_r) = layer_data[n + 1, :] rho = (rho_r * (z - z_l) + rho_l * (z_r - z)) / dz rho_theta = rho * (rho_theta_r / rho_r * (z - z_l) + rho_theta_l / rho_l * (z_r - z)) / dz diff --git a/examples/elixir_moist_euler_moist_bubble.jl b/examples/elixir_moist_euler_moist_bubble.jl index f082502..bdf7b4e 100644 --- a/examples/elixir_moist_euler_moist_bubble.jl +++ b/examples/elixir_moist_euler_moist_bubble.jl @@ -49,23 +49,23 @@ end struct AtmosphereLayers{RealT <: Real} equations::CompressibleMoistEulerEquations2D # structure: 1--> i-layer (z = total_height/precision *(i-1)), 2--> rho, rho_theta, rho_qv, rho_ql - LayerData::Matrix{RealT} + layer_data::Matrix{RealT} total_height::RealT preciseness::Int layers::Int ground_state::NTuple{2, RealT} - equivalentpotential_temperature::RealT + equivalent_potential_temperature::RealT mixing_ratios::NTuple{2, RealT} end function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, ground_state = (1.4, 100000.0), - equivalentpotential_temperature = 320, + equivalent_potential_temperature = 320, mixing_ratios = (0.02, 0.02), RealT = Float64) @unpack kappa, p_0, c_pd, c_vd, c_pv, c_vv, R_d, R_v, c_pl = equations rho0, p0 = ground_state r_t0, r_v0 = mixing_ratios - theta_e0 = equivalentpotential_temperature + theta_e0 = equivalent_potential_temperature rho_qv0 = rho0 * r_v0 T0 = theta_e0 @@ -73,7 +73,7 @@ function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, n = convert(Int, total_height / preciseness) dz = 0.01 - LayerData = zeros(RealT, n + 1, 4) + layer_data = zeros(RealT, n + 1, 4) F = generate_function_of_y(dz, y0, r_t0, theta_e0, equations) sol = nlsolve(F, y0) @@ -84,7 +84,7 @@ function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, kappa_M = (R_d * rho_d + R_v * rho_qv) / (c_pd * rho_d + c_pv * rho_qv + c_pl * rho_ql) rho_theta = rho * (p0 / p)^kappa_M * T * (1 + (R_v / R_d) * r_v) / (1 + r_t) - LayerData[1, :] = [rho, rho_theta, rho_qv, rho_ql] + layer_data[1, :] = [rho, rho_theta, rho_qv, rho_ql] for i in (1:n) y0 = deepcopy(sol.zero) dz = preciseness @@ -98,10 +98,10 @@ function AtmosphereLayers(equations; total_height = 10010.0, preciseness = 10, (c_pd * rho_d + c_pv * rho_qv + c_pl * rho_ql) rho_theta = rho * (p0 / p)^kappa_M * T * (1 + (R_v / R_d) * r_v) / (1 + r_t) - LayerData[i + 1, :] = [rho, rho_theta, rho_qv, rho_ql] + layer_data[i + 1, :] = [rho, rho_theta, rho_qv, rho_ql] end - return AtmosphereLayers{RealT}(equations, LayerData, total_height, dz, n, ground_state, + return AtmosphereLayers{RealT}(equations, layer_data, total_height, dz, n, ground_state, theta_e0, mixing_ratios) end @@ -110,8 +110,8 @@ end # Models, MonthlyWeather Review Vol.130, 2917–2928, 2002, # https://journals.ametsoc.org/view/journals/mwre/130/12/1520-0493_2002_130_2917_absfmn_2.0.co_2.xml. function initial_condition_moist_bubble(x, t, equations::CompressibleMoistEulerEquations2D, - AtmosphereLayers::AtmosphereLayers) - @unpack LayerData, preciseness, total_height = AtmosphereLayers + atmosphere_layers::AtmosphereLayers) + @unpack layer_data, preciseness, total_height = atmosphere_layers dz = preciseness z = x[2] if (z > total_height && !(isapprox(z, total_height))) @@ -119,13 +119,13 @@ function initial_condition_moist_bubble(x, t, equations::CompressibleMoistEulerE end n = convert(Int, floor((z + eps()) / dz)) + 1 z_l = (n - 1) * dz - (rho_l, rho_theta_l, rho_qv_l, rho_ql_l) = LayerData[n, :] + (rho_l, rho_theta_l, rho_qv_l, rho_ql_l) = layer_data[n, :] z_r = n * dz if (z_l == total_height) z_r = z_l + dz n = n - 1 end - (rho_r, rho_theta_r, rho_qv_r, rho_ql_r) = LayerData[n + 1, :] + (rho_r, rho_theta_r, rho_qv_r, rho_ql_r) = layer_data[n + 1, :] rho = (rho_r * (z - z_l) + rho_l * (z_r - z)) / dz rho_theta = rho * (rho_theta_r / rho_r * (z - z_l) + rho_theta_l / rho_l * (z_r - z)) / dz diff --git a/test/test_2d_moist_euler.jl b/test/test_2d_moist_euler.jl index 81c965e..d669e96 100644 --- a/test/test_2d_moist_euler.jl +++ b/test/test_2d_moist_euler.jl @@ -7,7 +7,7 @@ include("test_trixiatmo.jl") # TODO - This is a repetition from Trixi.jl EXAMPLES_DIR = pkgdir(TrixiAtmo, "examples") # TODO - Do we need a subdirectory for examples? -@trixiatmo_testset "elixir_moist_euler_dry_bubble.jl" begin +@trixiatmo_testset "elixir_moist_euler_dry_bubble" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_moist_euler_dry_bubble.jl"), l2=[