Skip to content

Commit

Permalink
start revising composition inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
chengcli committed Apr 6, 2024
1 parent 410f881 commit 4eab1f5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/inversion/composition_inversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,30 @@ void CompositionInversion::UpdateModel(MeshBlock *pmb,
Application::Logger app("inversion");
app->Log("Update Model");

// int is = pblock_->is, ie = pblock_->ie;
auto air = AirParcel::gather_from_primitive(pmb, k, ju_, pmb->is);
air.ToMoleFraction();

int iter = 0, max_iter = 200;
while (iter++ < max_iter) {
// read in vapors
for (auto n : GetSpeciesIndex()) {
air.w[n] = par[n];
}

// stop at just above P0
for (int i = is; i <= ie; ++i) {
pthermo->Extrapolate(&air, -dlnp / 2., "dry");
if (air.w[IPR] < P0) break;
}

// extrapolate down to where air is
pthermo->Extrapolate(&air, log(P0 / air.w[IPR]), "dry");

// make up for the difference
Ts += T0 - air.w[IDN];
if (std::abs(T0 - air.w[IDN]) < 0.01) break;

// app->Log("Iteration #", iter);
// app->Log("T", air.w[IDN]);
}
}

0 comments on commit 4eab1f5

Please sign in to comment.