From 50bff348e455b607c2a1fd7df6cf60bdc84232b7 Mon Sep 17 00:00:00 2001 From: Ben Dudson Date: Fri, 16 Aug 2024 21:44:19 -0700 Subject: [PATCH] sheath_boundary_simple: Fix Ve for supersonic flow When phi is not set, and Vi is supersonic, Ve would be set to sonic speed. The fix maintains Ve = Vi for subsonic and supersonic cases. --- src/sheath_boundary_simple.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sheath_boundary_simple.cxx b/src/sheath_boundary_simple.cxx index 87df9d9b..db7d97c7 100644 --- a/src/sheath_boundary_simple.cxx +++ b/src/sheath_boundary_simple.cxx @@ -166,6 +166,9 @@ void SheathBoundarySimple::transform(Options& state) { const Field3D Ti = getNoBoundary(species["temperature"]); const BoutReal Mi = getNoBoundary(species["AA"]); const BoutReal Zi = getNoBoundary(species["charge"]); + Field3D Vi = species.isSet("velocity") + ? toFieldAligned(getNoBoundary(species["velocity"])) + : zeroFrom(Ni); if (lower_y) { // Sum values, put result in mesh->ystart @@ -193,7 +196,12 @@ void SheathBoundarySimple::transform(Options& state) { // Sound speed squared BoutReal C_i_sq = (sheath_ion_polytropic * tisheath + Zi * tesheath) / Mi; - ion_sum[i] += Zi * nisheath * sqrt(C_i_sq); + BoutReal visheath = -sqrt(C_i_sq); + if (Vi[i] < visheath) { + visheath = Vi[i]; + } + + ion_sum[i] -= Zi * nisheath * visheath; } } } @@ -219,7 +227,12 @@ void SheathBoundarySimple::transform(Options& state) { BoutReal C_i_sq = (sheath_ion_polytropic * tisheath + Zi * tesheath) / Mi; - ion_sum[i] += Zi * nisheath * sqrt(C_i_sq); + BoutReal visheath = sqrt(C_i_sq); + if (Vi[i] > visheath) { + visheath = Vi[i]; + } + + ion_sum[i] += Zi * nisheath * visheath; } } }