Skip to content

Commit

Permalink
Improved handling of lower theremalised boundary conditions in 2D and…
Browse files Browse the repository at this point in the history
… synthesis of final column vertical rays; some small causing final column to degenerate to linear
  • Loading branch information
Goobley committed Aug 12, 2021
1 parent 3d581bb commit 53c2da0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.md
include LCIENSE
include LICENSE
include environment.yml
recursive-include lightweaver/Data/ *
recursive-include lightweaver/Data/ *
1 change: 1 addition & 0 deletions Source/FormalScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ void piecewise_bezier3_1d(FormalData* fd, int la, int mu, bool toObs, f64 wav)
{
if (atmos->zLowerBc.type == THERMALISED)
{
// NOTE(cmo): Trying to fulfill diffusion condition.
f64 Bnu[2];
int Nspace = atmos->Nspace;
planck_nu(2, &atmos->temperature(Nspace - 2), wav, Bnu);
Expand Down
34 changes: 33 additions & 1 deletion Source/FormalScalar2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,21 @@ void piecewise_linear_2d(FormalData* fd, int la, int mu, bool toObs, f64 wav)
{
case THERMALISED:
{
// NOTE(cmo): This becomes a problem for j == jEnd with
// non-periodic boundary conditions; RH appears to just ignore
// this column when using fixed boundaries, which makes sense,
// since we can't truly accumulate the Lambda operator anyway.
// Nevertheless, this gradient is likely to be similar from the
// preceeding point to this one, so let's recompute that and use
// it. Admittedly this is a bit of a HACK, but is likely to
// introduce very little error.
auto dwIntersection = intersections(mu, (int)toObs, k, j).dwIntersection;
if ((!periodic) && (j == jEnd) && (mux != 0.0))
{
// NOTE(cmo): This assumes the atmosphere is wider than one
// column... but it has to be really.
dwIntersection = intersections(mu, (int)toObs, k, j-dj).dwIntersection;
}
f64 chiDw = interp_param(gridData, dwIntersection, chi);
f64 dtauDw = 0.5 * abs(dwIntersection.distance) * (chi(k, j) + chiDw);
f64 temperatureDw = interp_param(gridData, dwIntersection, temperature);
Expand Down Expand Up @@ -859,7 +873,21 @@ void piecewise_besser_2d(FormalData* fd, int la, int mu, bool toObs, f64 wav)
{
case THERMALISED:
{
// NOTE(cmo): This becomes a problem for j == jEnd with
// non-periodic boundary conditions; RH appears to just ignore
// this column when using fixed boundaries, which makes sense,
// since we can't truly accumulate the Lambda operator anyway.
// Nevertheless, this gradient is likely to be similar from the
// preceeding point to this one, so let's recompute that and use
// it. Admittedly this is a bit of a HACK, but is likely to
// introduce very little error.
auto dwIntersection = intersections(mu, (int)toObs, k, j).dwIntersection;
if ((!periodic) && (j == jEnd) && (mux != 0.0))
{
// NOTE(cmo): This assumes the atmosphere is wider than one
// column... but it has to be really.
dwIntersection = intersections(mu, (int)toObs, k, j-dj).dwIntersection;
}
f64 chiDw = interp_param(gridData, dwIntersection, chi);
f64 dtauDw = 0.5 * abs(dwIntersection.distance) * (chi(k, j) + chiDw);
f64 temperatureDw = interp_param(gridData, dwIntersection, temperature);
Expand Down Expand Up @@ -1219,6 +1247,10 @@ void build_intersection_list(Atmosphere* atmos)
IntersectionResult uw(InterpolationAxis::None, k, j, 0.0);
auto dw = dw_intersection_2d(gridData, k, j);
dw.distance = abs(dw.distance);

if ((!periodic) && (j == jEnd) && (mux != 0.0))
dw = IntersectionResult(InterpolationAxis::None, k, j, 0.0);

intersections(mu, toObsI, k, j) = InterpolationStencil{uw, dw, -1, -1};
}
k += dk;
Expand Down Expand Up @@ -1263,7 +1295,7 @@ void build_intersection_list(Atmosphere* atmos)
IntersectionResult dw;
if (k != kEnd)
{
if ((!periodic) && (j == jEnd))
if ((!periodic) && (j == jEnd) && (mux != 0.0))
{
dw = IntersectionResult(InterpolationAxis::None, k, j, 0.0);
}
Expand Down

0 comments on commit 53c2da0

Please sign in to comment.