51 analytical inlet module#110
Conversation
|
Awesome, taking a look at it now! Would you mind if I make minor changes as I review? I'll avoid modifying the functionality and focus on code style, variable names, and type annotations. |
|
@TimothyEDawson I don't mind at all, thanks for helping clean up the admittedly lengthy code! |
|
@nlaing613 Alrighty, I've got a few things to clean up but overall it's looking pretty good. I did notice the hyshot_inlet example case crashes, so if you want to look into that in the mean time please feel free. If it's going to take a while to fix no worries, we'll merge this in and work on that in a subsequent pull request. |
Added some type annotations, but still much work to be done. Started using match-case in place of chained if clauses. Dropping use of `math` in favor of NumPy-only calls. Pull in Matplotlib style sheet instead of hardcoding it.
TimothyEDawson
left a comment
There was a problem hiding this comment.
I'm good with merging this in as-is and fixing the rest later, but some misc. comments on things to improve going forward:
- I don't typically use the
mathmodule when we already use NumPy so extensively. I'd rather just use NumPy exclusively. - I recommend avoiding unpacking NumPy arrays, like when you unpack
x, y, V, theta, p, rho = pt. There are several options for rewriting this sort of logic, but it's hard to recommend one without fully understanding the overall flow of data. - The logic and type annotations can be substantially simplified by avoiding unnecessary uses of
None. Examples:- For invalid cases, raise an error instead of returning
None. E.g. inchar_net.point_mask, is there any valid path through the calling program where a returnedNonewould be valid? - In
NetShockSolver, areself.net_Rorself.net_R_testever intended to beNone? Many type errors disappeared by simply not initializing them withNonevalues, i.e. assuming they will always be of typeCharNet.
- For invalid cases, raise an error instead of returning
- I see invalid calls to
wall_point_rotinCharNet- looks like you added thewallandfamilyinput arguments to the signature but didn't update the calls here?
This PR adds the first fully operational version of the
inlet_mocmodule and an associated test case (emami_inlet.py). It is not ready to directly integrate in the same manner assimple_inlet_model.py, but it works nicely for this test case and the code is large. I reason it'd be better to start this sooner than later.Sources:
rotational_solvers.pyis adapted from Zucrow and Hoffman, Volume II, Chapter 17. The irrotational shock-net algorithm is documented in SUPIN and Anderson NASA TN D-4960. I extended the irrotational shock algorithm for rotational solvers, where irrotational flow is a special case of rotational flow. This should make the solver more accurate and robust, as shocks violate the irrotationality assumption (Crocco's theorem).Ruff formatting/checks were also run before opening this PR.
Note: throughout the code, the
np.ndarrayvariableptis used. This always containsx,y,V,theta,p, andrho. I am open to changing this to a dataclass, but since points are constantly called from the net, repackaging them seems wasteful.Module Structure
moc_solution.pyinitial_domain.pyFlowCells containing the freestream, post-shock state, and initial data line (IDL).solver_events.pyplanar_inlet.pymathmodule interpolation to return theylocation of the two walls, centerbody and cowl, and their slopes at a givenx.char_net.pyx,y,V,theta,p, andrho.flow_physics.pyrotational_solvers.pyfield_point_rot, the solver for the intersection ofC+andC-characteristics, reconstructing theC0streamline.wall_point_rot, the solver for the intersection of the wall (C0) and two characteristic points.utils_moc.pyShock Solvers
shock_solvers/char_shock.pynet_L) and downstream net points (net_R) that satisfy oblique shock relations and characteristic/compatibility equations.ShockPointclass.shock_solvers/net_logic_helpers.pynet_shock.py.shock_solvers/net_shock.pynet_L.net_Rto retain user-specified resolution.Processing
processing/processing.pydirectandanalyticalmodes, with user-specified sampling resolution for analytical mode.processing/triangulated_solution.pyy.processing/get_streamtube_bounds.pyprocessing/cross_sectional_average.pyPlotting
plot/net_shock.pyplot_during_solveis specified, generates a real-time plot of the net-shock marching process.plot/solution.pyplot/helpers.pyExample Case
examples/moc_testing/emami_inlet.pyx_stopand IDL resolution.get_streamtube_bounds.pyversus the analytical function provided in the original paper.Next Steps
Wire the inlet solver more directly into StanShock’s geometry infrastructure.
Isolate the thermodynamic model.