Rise
The Vieneo Province
Loading...
Searching...
No Matches
OrbitDescent.h
Go to the documentation of this file.
1#pragma once
2#include "OrbitArrival.h"
3#include "OrbitEntryPhysics.h"
5
6namespace Orbital { namespace Descent {
7// Requested Rise approach geometry, not an Earth shuttle flight envelope.
8// The last 10 km (or a more distant loaded marker) remain a 3-degree final.
9constexpr double Steep=20*Pi/180, FinalAngle=3*Pi/180;
10struct Path {
12 double Slope(double distance) const {
13 const double f=(std::clamp)((distance-gateDistance)/blend,0.0,1.0);
14 return std::tan(FinalAngle)+(std::tan(Steep)-std::tan(FinalAngle))*f;
15 }
16 double Height(double distance) const {
17 const double x=(std::max)(0.0,distance-gateDistance),b=(std::min)(x,blend);
18 return gateHeight+std::tan(FinalAngle)*b+
19 (std::tan(Steep)-std::tan(FinalAngle))*b*b/(2*blend)+
20 std::tan(Steep)*(x-b);
21 }
22};
23inline Path Geometry(const Input&,const Request& r,const ArrivalPreview& gate)
24{
26 // At the selected handoff speed, spread the pullout over at least 40 s.
27 // This is a controller response allowance. Forces are checked separately.
28 p.blend=(std::max)(10.0,r.entrySpeedKms*40);
29 const double rise=r.entryAltitudeKm-p.gateHeight;
30 if(rise<=0) return p;
31 const double turnHeight=p.Height(p.gateDistance+p.blend)-p.gateHeight;
32 if(rise>=turnHeight) p.range=p.gateDistance+p.blend+(rise-turnHeight)/std::tan(Steep);
33 else {
34 const double a=(std::tan(Steep)-std::tan(FinalAngle))/(2*p.blend),b=std::tan(FinalAngle);
35 p.range=p.gateDistance+2*rise/(b+std::sqrt(b*b+4*a*rise));
36 }
37 return p;
38}
39inline double FinalIas(const Input&,double stall,double vref)
40{ return (std::max)(vref,1.3*stall); }
41inline double SpeedLimit(const Input& in,State state,double altitude,double distance,
42 const Path& path,double stall,double vref,double aft,double vertical)
43{
44 const auto air=EntryPhysics::Atmosphere(in,state);
45 if(!(air.ias>0&&Norm(air.velocity)>0&&stall>0&&vref>0)) return NAN;
46 const double finalIas=FinalIas(in,stall,vref);
47 // Keep high IAS until braking for final is required. In particular, do not
48 // command Vref at 30 km. Look through spool/response into increasing density.
49 // Five speed-loop time constants, plus engine spool, cover the sharp IAS
50 // rise through this client's Mach-drag peak, including modeled drag error.
51 const double response=(std::max)(1.0,in.entryVehicle.spoolSeconds)+30;
52 const double futureHeight=(std::max)(path.gateHeight,altitude+(std::min)(0.0,vertical)*response);
53 auto airAt=[&](double speed,double height) {
54 auto probe=state;probe.r=Unit(state.r)*(in.radius+height);
55 probe.v=Cross({0,0,in.spin},probe.r)+EntryPhysics::Wind(in,probe.r)+Unit(air.velocity)*speed;
56 return EntryPhysics::Atmosphere(in,probe);
57 };
58 auto ceiling=[&](double height,double ias,bool thermal) {
59 auto fits=[&](double speed) {
60 const auto a=airAt(speed,height);
61 return a.ias<=ias&&(!thermal||EntryPhysics::Heat(in.entryVehicle,a,aft,response)<=195);
62 };
63 // Mach drag makes IAS/TAS nonlinear. Find the first unsafe interval,
64 // then refine it; scaling measured IAS alone misses the transonic peak.
65 double lo=0,hi=.025;
66 while(hi<2&&fits(hi)) {lo=hi;hi+=.025;}
67 for(int j=0;j<20;++j) {const double mid=(lo+hi)/2;if(fits(mid))lo=mid;else hi=mid;}
68 return lo;
69 };
70 double limit=ceiling(futureHeight,.90*in.vneKms,true);
71 const double finalTas=ceiling(path.gateHeight,finalIas,false);
72 const double remaining=(std::max)(0.0,distance-path.gateDistance-
73 Norm(air.velocity)*response-2);
74 // Reserve half the reverse authority for gravity, spool and tracking errors.
75 // The density ceiling above handles the much larger high-altitude TAS.
76 const double brake=.5*in.entryReverseKN/in.massKg;
77 limit=(std::min)(limit,std::sqrt(finalTas*finalTas+2*brake*remaining));
78 return limit;
79}
80inline bool AircraftHandoff(const Input& in,const Request& r,const ArrivalPreview& gate,State state,Vec acceleration) {
81 if(!(in.stallKms>0&&in.vrefKms>0)||!std::isfinite(in.stallKms)||!std::isfinite(in.vrefKms)) return false;
82 const auto air=EntryPhysics::Atmosphere(in,state);
83 if(air.ias<1.3*in.stallKms||air.ias>.9*in.vneKms) return false;
84 const Vec along=Unit(air.velocity),up=Unit(state.r-along*Dot(state.r,along));
85 const Vec required=acceleration-SurfacePlanning::Gravity(state.r,in.gm);
86 const double normal=Dot(required,up);
87 double low=INFINITY,high=-INFINITY;
88 for(const auto& a:in.entryAero) {
89 const double lift=Dot(EntryPhysics::AerodynamicForce(in,air,a,state.r),up)/in.massKg;
90 low=(std::min)(low,lift);high=(std::max)(high,lift);
91 }
92 // A/F must carry the aircraft without entry's translational RCS. Retain
93 // lift reserve for bank/tracking; stall and heating are checked separately.
94 if(normal<low||normal>high*.9) return false;
95 const auto demand=EntryPhysics::Forces(in,state,acceleration,in.massKg);
96 if(EntryEnvelope::Fraction(in,state,acceleration,demand)>EntryEnvelope::Reserve) return false;
98 const auto path=Geometry(in,r,gate);
99 const double limit=SpeedLimit(in,state,r.entryAltitudeKm,path.range,path,in.stallKms,in.vrefKms,
100 in.entryVehicle.aftC,Dot(state.v,Unit(state.r)));
101 if(!std::isfinite(limit)||r.entrySpeedKms>limit) return false;
102 }
103 return true;
104}
105}}
bool AircraftHandoff(const Input &in, const Request &r, const ArrivalPreview &gate, State state, Vec acceleration)
double FinalIas(const Input &, double stall, double vref)
constexpr double FinalAngle
Definition OrbitDescent.h:9
double SpeedLimit(const Input &in, State state, double altitude, double distance, const Path &path, double stall, double vref, double aft, double vertical)
Path Geometry(const Input &, const Request &r, const ArrivalPreview &gate)
constexpr double Steep
Definition OrbitDescent.h:9
double Fraction(const Input &in, Vec g)
constexpr double Reserve
Vec AerodynamicForce(const Input &in, const Air &air, const AeroPoint &aero, Vec radial)
Vec Wind(const Input &in, Vec position)
Air Atmosphere(const Input &in, State state, double angle=0, bool measured=false)
Demand Forces(const Input &in, State state, Vec acceleration, double mass, bool measured=false)
double Heat(const EntryVehicle &v, const Air &air, double aftC, double seconds)
Vec Gravity(Vec r, double gm)
Definition OrbitProfile.h:5
Vec Unit(Vec a)
Definition OrbitMath.h:20
double Dot(Vec a, Vec b)
Definition OrbitMath.h:16
constexpr double Pi
Definition OrbitMath.h:10
double Norm(Vec a)
Definition OrbitMath.h:18
Vec Cross(Vec a, Vec b)
Definition OrbitMath.h:17
double Height(double distance) const
double Slope(double distance) const
double aftC
Definition OrbitState.h:86
double spoolSeconds
Definition OrbitState.h:87
EntryVehicle entryVehicle
Definition OrbitState.h:123
std::array< AeroPoint, 9 > entryAero
Definition OrbitState.h:114
double entryReverseKN
Definition OrbitState.h:111
double entryAltitudeKm
Definition OrbitState.h:69
double entrySpeedKms
Definition OrbitState.h:69