From b8accfe148813d0539adf9b517d0b015723249ff Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Tue, 28 May 2024 15:04:51 +0100 Subject: [PATCH 1/4] Change energy flow diagnostic factor from 3/2 to 5/2 - Seems to make energy imbalance less imbalanced, but I haven't gone through the maths yet --- src/neutral_mixed.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/neutral_mixed.cxx b/src/neutral_mixed.cxx index 0d3958cd..7d9811eb 100644 --- a/src/neutral_mixed.cxx +++ b/src/neutral_mixed.cxx @@ -417,8 +417,8 @@ void NeutralMixed::finally(const Options& state) { + Div_a_Grad_perp_upwind_flows(DnnPn, logPnlim, energy_flow_xlow, energy_flow_ylow) // Perpendicular advection ; - energy_flow_xlow *= 3/2; // Note: Should this be 5/2? - energy_flow_ylow *= 3/2; + energy_flow_xlow *= 5/2; // Note: Should this be 5/2? + energy_flow_ylow *= 5/2; if (neutral_conduction) { ddt(Pn) += FV::Div_a_Grad_perp(DnnNn, Tn) // Perpendicular conduction From 0aa087b0c2b21e6445a0f84400b11c813fff573a Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Tue, 28 May 2024 15:21:21 +0100 Subject: [PATCH 2/4] Change conduction to upwind and expose fluxes --- include/neutral_mixed.hxx | 1 + src/neutral_mixed.cxx | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/neutral_mixed.hxx b/include/neutral_mixed.hxx index baaff4de..3747878f 100644 --- a/include/neutral_mixed.hxx +++ b/include/neutral_mixed.hxx @@ -73,6 +73,7 @@ private: Field3D particle_flow_xlow, particle_flow_ylow; Field3D momentum_flow_xlow, momentum_flow_ylow; Field3D energy_flow_xlow, energy_flow_ylow; + Field3D conduction_flow_xlow, conduction_flow_ylow; }; namespace { diff --git a/src/neutral_mixed.cxx b/src/neutral_mixed.cxx index 7d9811eb..3b71815b 100644 --- a/src/neutral_mixed.cxx +++ b/src/neutral_mixed.cxx @@ -421,7 +421,8 @@ void NeutralMixed::finally(const Options& state) { energy_flow_ylow *= 5/2; if (neutral_conduction) { - ddt(Pn) += FV::Div_a_Grad_perp(DnnNn, Tn) // Perpendicular conduction + ddt(Pn) += Div_a_Grad_perp_upwind_flows(DnnNn, Tn, + conduction_flow_xlow, conduction_flow_ylow) // Perpendicular conduction + FV::Div_par_K_Grad_par(DnnNn, Tn) // Parallel conduction ; } @@ -646,6 +647,26 @@ void NeutralMixed::outputVars(Options& state) { {"species", name}, {"source", "evolve_pressure"}}); } + if (conduction_flow_xlow.isAllocated()) { + set_with_attrs(state[std::string("ConductionFlow_") + name + std::string("_xlow")],conduction_flow_xlow, + {{"time_dimension", "t"}, + {"units", "W"}, + {"conversion", rho_s0 * SQ(rho_s0) * Pnorm * Omega_ci}, + {"standard_name", "power"}, + {"long_name", name + " conducted power through X cell face. Note: May be incomplete."}, + {"species", name}, + {"source", "evolve_pressure"}}); + } + if (conduction_flow_ylow.isAllocated()) { + set_with_attrs(state[std::string("ConductionFlow_") + name + std::string("_ylow")], conduction_flow_ylow, + {{"time_dimension", "t"}, + {"units", "W"}, + {"conversion", rho_s0 * SQ(rho_s0) * Pnorm * Omega_ci}, + {"standard_name", "power"}, + {"long_name", name + " conducted power through Y cell face. Note: May be incomplete."}, + {"species", name}, + {"source", "evolve_pressure"}}); + } } } From 20271186f853a3ab27db7358ceff365f31722ea3 Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Tue, 28 May 2024 15:26:42 +0100 Subject: [PATCH 3/4] Add comments on flow diags and fix conduction one --- src/neutral_mixed.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/neutral_mixed.cxx b/src/neutral_mixed.cxx index 3b71815b..b1d7065c 100644 --- a/src/neutral_mixed.cxx +++ b/src/neutral_mixed.cxx @@ -417,7 +417,10 @@ void NeutralMixed::finally(const Options& state) { + Div_a_Grad_perp_upwind_flows(DnnPn, logPnlim, energy_flow_xlow, energy_flow_ylow) // Perpendicular advection ; - energy_flow_xlow *= 5/2; // Note: Should this be 5/2? + + // The factor here is likely 5/2 as we're advecting internal energy and pressure. + // Doing this still leaves a heat imbalance factor of 0.11 in the cells, but better than 0.33 with 3/2. + energy_flow_xlow *= 5/2; energy_flow_ylow *= 5/2; if (neutral_conduction) { @@ -426,6 +429,10 @@ void NeutralMixed::finally(const Options& state) { + FV::Div_par_K_Grad_par(DnnNn, Tn) // Parallel conduction ; } + + // The factor here is likely 3/2 as this is pure energy flow, but needs checking. + energy_flow_xlow *= 3/2; + energy_flow_ylow *= 3/2; Sp = pressure_source; if (localstate.isSet("energy_source")) { From c095e434c5dcae3572d03db8d6e26dfa2917d22f Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Tue, 28 May 2024 15:30:25 +0100 Subject: [PATCH 4/4] Fix typo --- src/neutral_mixed.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/neutral_mixed.cxx b/src/neutral_mixed.cxx index b1d7065c..abf75420 100644 --- a/src/neutral_mixed.cxx +++ b/src/neutral_mixed.cxx @@ -431,8 +431,8 @@ void NeutralMixed::finally(const Options& state) { } // The factor here is likely 3/2 as this is pure energy flow, but needs checking. - energy_flow_xlow *= 3/2; - energy_flow_ylow *= 3/2; + conduction_flow_xlow *= 3/2; + conduction_flow_ylow *= 3/2; Sp = pressure_source; if (localstate.isSet("energy_source")) {