Kerbal Space Program  1.12.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
FlightIntegrator Class Reference

This script adds all external forces to the ship parts. More...

Inheritance diagram for FlightIntegrator:
VesselModule

Public Member Functions

virtual double CalcConvectiveCoefficient (Vessel.Situations situation)
 Calculates a convective coefficient, for convective transfer = coeff * area * (air temp - skin temp) Handles the splashed case, then if in air lerps between Newtonian and Mach (Hypersonic) convection based on the Newtonian-Mach lerp and the craft's Mach number. More...
 
virtual double CalculateAnalyticTemperature ()
 Calculates analytically a steady-state temperature for the entire vessel using the vessel's emissive and absorptive-weighted radiative area, the incoming solar flux, any body flux, any atmospheric convection, and any internal generation. Conduction is entirely ignored (it is assumed to be near-instantaneous on these timescalse) and convection is also guesstimated on a final-analysis, steady-state basis (basically lerping between external temperature and pure radiative-balance temperature based on atmospheric density). This supports callbacks to parts using various interfaces. More...
 
virtual double CalculateDensityThermalLerp ()
 Calculates a lerp value for use in determining background radiation temp and for steady-state temperatures w.r.t convection in analytic mode. NOTE: Uses the post-shockwave density, not the static density More...
 
virtual double CalculateShockTemperature ()
 Calculates the shock temperature given a velocity More...
 
virtual double GetBodyArea (PartThermalData ptd)
 Get radiative area facing the body More...
 
override int GetOrder ()
 
virtual double GetSunArea (PartThermalData ptd)
 Get radiative area facing the sun More...
 
override void OnLoadVessel ()
 
override void OnUnloadVessel ()
 
virtual void PrecalcConduction (PartThermalData ptd)
 Sets the conduciton multiplier and skin-skin transfer multiplier for a PTD The latter starts from sqrt(radiative area) and then tries to take the relative areas of exposed and unexposed skin into account, i.e. it's maximal when about half is exposed and half unexposed More...
 
virtual void PrecalcConvection (PartThermalData ptd)
 Determine the final convective coefficient based on occlusion and convective stats More...
 
virtual void PrecalcRadiation (PartThermalData ptd)
 Precalc radiative stats like final coefficients and the final background rad temp exposed and unexposed. This is complicated because we need to figure out what portion of sun and body flux each apply to exposed and to unexposed skin (this is done by taking the dot of the sun vector vs the velocity vector and the -upaxis and the velocity vector respectively). All these get stored as incoming fluxes, since they are constant given a position and orientation and so needn't be recalculated during all the RK2 steps. More...
 
virtual void SetSkinProperties (PartThermalData ptd)
 Sets the basic skin properties for this thermal pass. Calculate the total area, the fraction of which is exposed or unexposed, and handle any transfers in thermal energy when those areas change. More...
 
virtual void SetSkinThermalMass (Part part)
 Determine skin thermal mass from radiative area and part dry mass More...
 
virtual void Setup ()
 
override bool ShouldBeActive ()
 
virtual void ThermalIntegrationPass (bool averageWithPrevious)
 The actual thermal integration pass. First update conduction (this merely establishes fluxes). Then loop through all PTDs. Store previous temps if we're doing RK2 passes, then calculte convection and radiation for the part. Finally apply the fluxes. More...
 
virtual void ThermoPrecalculate ()
 Any not-every-frame thermo calcs More...
 
virtual void UnifySkinTemp (PartThermalData ptd)
 Unifies the exposed and unexposed skin temps into a unified temp using the whole skin thermal mass More...
 
virtual void Update ()
 Recalculate those bits that don't need to happen every frame (for now, the sun and body fluxes / air temperature offsets More...
 
virtual void UpdateCompoundParts ()
 Apply thermal links based on compound parts More...
 
virtual void UpdateConduction ()
 The big one. Processes conduction across the vessel. Occurs in multiple passes. The first pass involves zeroing fluxes and getting unified skin temperatures. Then internal conduction happens (i.e. part internal <-> part internal, no skin). The PTDs are sorted by int temp, and then each PTD's links are checked. Heat pushes out to the links based on the conductive coefficient and the attach area. Checks are done to ensure stability. Since we start from hottest first, the hottest parts get priority flowing heat outwards. The same occurs for part skin <-> part skin conduction. Finally skin-skin conduction is computed for individual parts, between exposed and unexposed skin. Note that throughout this process only fluxes are stored. More...
 
virtual void UpdateConvection (PartThermalData ptd)
 Process convection in the simple flux = coeff * t_delta manner More...
 
virtual void UpdateRadiation (PartThermalData ptd)
 Apply incoming fluxes to part radiative fluxes and also calculate outgoing rad flux based on black-body radiation. More...
 
- Public Member Functions inherited from VesselModule
virtual Activation GetActivation ()
 
void Load (ConfigNode node)
 
virtual void OnGoOffRails ()
 
virtual void OnGoOnRails ()
 
void Save (ConfigNode node)
 

Public Attributes

double altitude
 Vessel velocity members. More...
 
double atmosphereTemperatureOffset
 based on latitude, sun angle, etc. More...
 
double atmosphericTemperature
 
double backgroundRadiationTemp
 
double backgroundRadiationTempExposed
 
double bodyAlbedoFlux
 in kW/m^2 More...
 
double bodyEmissiveFlux
 in kW/m^2 More...
 
Vector3 CoM
 
Vector3d CoMd
 
List< CompoundPartcompoundParts
 We have to keep track of compound parts specially More...
 
int compoundPartsTimer = 0
 
double convectiveCoefficient
 
double convectiveMachFlux
 
double convectiveMachLerp
 
double density
 
double dynamicPressurekPa
 
double externalTemperature
 
bool firstFrame = true
 
Vector3 GraviticAcceleration
 
bool isAnalytical = false
 Are we in Analytic mode? More...
 
bool isKerbal = false
 
bool isRunning = false
 
double mach
 
bool needOcclusion = true
 Solar, Body. More...
 
OcclusionCylinder[] occludersBody
 
int occludersBodyCount
 
OcclusionCone[] occludersConvection
 
int occludersConvectionCount
 
OcclusionCylinder[] occludersSun
 
int occludersSunCount
 
List< PartThermalDatapartThermalDataList = new List<PartThermalData>()
 The set of PTDs, one per part with nonzero thermal mass. This is sorted by internal temp More...
 
List< PartThermalDatapartThermalDataListSkin = new List<PartThermalData>()
 Same set of PTDs, sorted by skin temp More...
 
int passes = 0
 
double pseudoReDragMult = 1d
 
double pseudoReLerpTimeMult = 1d
 
double pseudoReynolds
 
double realDistanceToSun
 
double solarAirMass
 solar air mass multiplier More...
 
double solarFlux
 
double solarFluxMultiplier
 reduction to solar flux due to atmospheric absorption/scattering/etc More...
 
double spd
 
double staticPressureAtm
 
double staticPressurekPa
 
double sunDot
 dot between terrain surface normal and sun. More...
 
Vector3 sunVector
 the vector to the sun More...
 
double timeSinceLastUpdate = 0d
 

Static Public Attributes

static FlightIntegrator ActiveVesselFI = null
 
static CelestialBody sunBody
 

Protected Member Functions

void ApplyAeroDrag (Part part, UnityEngine.Rigidbody rbPossible, ForceMode mode)
 Apply aerodynamic force to the part More...
 
void ApplyAeroLift (Part part, UnityEngine.Rigidbody rbPossible, ForceMode mode)
 Apply aerodynamic force to the part More...
 
virtual double CalculateAerodynamicArea (Part part)
 
virtual double CalculateAreaExposed (Part part)
 
virtual double CalculateAreaRadiative (Part part)
 
double CalculateAtmosphericDensity (double pres, double temp)
 
virtual double CalculateBackgroundRadiationTemperature (double ambientTemp)
 This is the temperature of background radiation yields correct value for sea level in Earth atmosphere, more or less other values are my best guess. Uses the densityThermalLerp More...
 
virtual void CalculateConstantsAtmosphere ()
 Calculate the basic constants (pressure, density, solar flux, etc) when in atmosphere. Does solar air mass calcs, applies atmosphere temperature offset, calculates shock temp and convection stats, etc. More...
 
virtual void CalculateConstantsVacuum ()
 Calculate the basic constants (pressure, density, solar flux, etc) when in vacuum More...
 
virtual double CalculateConvectiveCoefficient ()
 Calculates a convective coefficient, for convective transfer = coeff * area * (air temp - skin temp) Handles the splashed case, then if in air lerps between Newtonian and Mach (Hypersonic) convection based on the Newtonian-Mach lerp and the craft's Mach number. More...
 
virtual double CalculateConvectiveCoefficient (Vessel.Situations situation)
 Calculates a convective coefficient, for convective transfer = coeff * area * (air temp - skin temp) Handles the splashed case, then if in air lerps between Newtonian and Mach (Hypersonic) convection based on the Newtonian-Mach lerp and the craft's Mach number. More...
 
virtual double CalculateConvectiveCoefficientMach ()
 Calculate high-speed convective coefficient. Simple function of const * dnesity^exponent * spd^exponent (the exponents differ) More...
 
virtual double CalculateConvectiveCoefficientNewtonian ()
 Calcuklate a coefficient for simple Newtonian convection Coeff ~= (density>1, density, else dnesity^exponent) * (base + spd^exponent) More...
 
virtual double CalculateDragValue (Part part)
 
virtual double CalculateDragValue_Conic (Part part)
 
virtual double CalculateDragValue_Cube (Part part)
 
virtual double CalculateDragValue_Cylindrical (Part part)
 
virtual double CalculateDragValue_Spherical (Part part)
 
virtual void CalculatePressure ()
 
virtual void CalculateSunBodyFlux ()
 Calculates the distance to the sun, the solar flux, and the atmospheric temperature characterists and body albedo/emissive flux More...
 
void CheckThermalGraph ()
 Check and recreate thermal graph More...
 
void DragCubeSetupAndPartAeroStats (Vessel v)
 
virtual void FixedUpdate ()
 Handle most physics integration More...
 
float GetPhysicslessChildMass (Part part)
 rewrite of the part method; this one accepts chains, and uses what we calculate in VesselPrecalculate More...
 
virtual void HookVesselEvents ()
 
virtual void Integrate (Part part)
 Apply all forces to the part, both via the part's force list and from gravity (if done here not in Precalc) and from drag/bodylift. Also calculate angular drag both in air and submerged More...
 
virtual void IntegratePhysicalObjects (List< physicalObject > pObjs, double atmDensity)
 Apply gravity and drag to physicalobjects More...
 
virtual void OnDestroy ()
 
void OnDrawGizmosSelected ()
 
void OnPartEvent (Part part)
 
void OnPartEventFromToAction (GameEvents.FromToAction< Part, Part > data)
 
void OnPartEventTargetAction (GameEvents.HostTargetAction< Part, Part > data)
 
override void OnStart ()
 
void OnVesselEvent (Vessel vessel)
 
virtual void SmoothVelocity ()
 Smooth velocity so frame shifts are not passed on to aero/thermo integration More...
 
virtual void UnhookVesselEvents ()
 
virtual void UpdateAerodynamics (Part part)
 Updates the aerodyanmics stats of the part and also handles calculating submerged dynamic pressure and total angular drag. More...
 
virtual void UpdateMassStats ()
 Precalculate thermal mass and resource mass while finding CoM and Velocity. More...
 
virtual void UpdateOcclusion (bool all)
 
void UpdateOcclusionBody ()
 
void UpdateOcclusionConvection ()
 
void UpdateOcclusionSolar ()
 
virtual void UpdateThermalGraph ()
 Rebuilds the thermal graph. This involves recreating all PTDs and PTLs, cleaing and recreating occluders, reapplying old settings on the new PTDs, and finally registering the various callback interfaces. More...
 
virtual void UpdateThermodynamics ()
 Main thermo method. First decides whether to run an analytic pass based off the last time a thermo pass was run (so when an unloaded vessel is loaded, analytic is run with the whole unloaded time, not just the current fixed frame time. If analytic, then that temp is applied, following any callbacks. If not, then all fluxes are zeroed and temps sanified, and then each of the Precalculate methods are run (for conduction, convection, and radiation). Finally some number of thermal integration paasses are run, either one pass using RK1 or a set of RK2 passes. More...
 
- Protected Member Functions inherited from VesselModule
void Awake ()
 
virtual void OnAwake ()
 
virtual void OnLoad (ConfigNode node)
 
virtual void OnSave (ConfigNode node)
 
void Start ()
 

Protected Attributes

CelestialBody currentMainBody
 Used to prevent calculating external temperature several times before fixedUpdate is called in the flightIntegrator (i.e. if more than one part tries to in the same frame) More...
 
double deltaTime = 0d
 
double densityThermalLerp
 
double fDeltaTime
 
double fDeltaTimeRecip
 
double fTimeSinceThermo = 0d
 
double fTimeSinceThermoRecip
 
Transform integratorTransform
 
const double KPA2ATM = 1d / 101.325d
 
Vector3 lastVel
 
int lastVelIndex
 
bool lastVelProvisional = false
 
double maxVelDeltaSqr = 1000d * 1000d
 Vessel stats. More...
 
List< IAnalyticOverheatModuleoverheatModules = new List<IAnalyticOverheatModule>()
 list of IAnalyticOverheatModule for analytic callbacks More...
 
int partCount = 0
 
Part partRef
 
int partThermalDataCount = 0
 
double passesRecip = 1d
 
List< IAnalyticPreviewpreviewModules = new List<IAnalyticPreview>()
 List of preview modules for analytic callbakcs More...
 
bool recreateThermalGraph = true
 
bool setupRun = false
 
double timeFactor = 0.02d
 
int VelIndex = 0
 
Vector3[] VelSmoother
 
double VelSmoothLenRecip
 
bool VelSpiking = false
 
bool wasMachConvectionEnabled = false
 
- Protected Attributes inherited from VesselModule
BaseFieldList fields
 
Vessel vessel
 

Static Protected Attributes

static int sunLayerMask
 
static int VelSmoothLen = 10
 

Additional Inherited Members

- Public Types inherited from VesselModule
enum  Activation {
  Activation.FlightScene = 1, Activation.NonFlightScenes = 2, Activation.LoadedVessels = 4, Activation.UnloadedVessels = 8,
  Activation.Never = 0, Activation.AllScenes = 3, Activation.LoadedOrUnloaded = 12, Activation.Always = 255
}
 
- Properties inherited from VesselModule
BaseFieldList Fields [get]
 
Vessel Vessel [get, set]
 

Detailed Description

This script adds all external forces to the ship parts.

Member Function Documentation

void FlightIntegrator.ApplyAeroDrag ( Part  part,
UnityEngine.Rigidbody  rbPossible,
ForceMode  mode 
)
inlineprotected

Apply aerodynamic force to the part

Parameters
partthe part
rbPossiblethe rigidbody (either part or part.parent)
modethe mode of force to apply
void FlightIntegrator.ApplyAeroLift ( Part  part,
UnityEngine.Rigidbody  rbPossible,
ForceMode  mode 
)
inlineprotected

Apply aerodynamic force to the part

Parameters
partthe part
rbPossiblethe rigidbody (either part or part.parent)
modethe mode of force to apply

< rotate the lift force into world coords

< exclude anything in the drag direction, we're not worrying about drag here

< finally, add the force.

virtual double FlightIntegrator.CalcConvectiveCoefficient ( Vessel.Situations  situation)
inlinevirtual

Calculates a convective coefficient, for convective transfer = coeff * area * (air temp - skin temp) Handles the splashed case, then if in air lerps between Newtonian and Mach (Hypersonic) convection based on the Newtonian-Mach lerp and the craft's Mach number.

Parameters
situationSet to a Vessel.Situation to use for the calculation.
Returns
virtual double FlightIntegrator.CalculateAerodynamicArea ( Part  part)
inlineprotectedvirtual
virtual double FlightIntegrator.CalculateAnalyticTemperature ( )
inlinevirtual

Calculates analytically a steady-state temperature for the entire vessel using the vessel's emissive and absorptive-weighted radiative area, the incoming solar flux, any body flux, any atmospheric convection, and any internal generation. Conduction is entirely ignored (it is assumed to be near-instantaneous on these timescalse) and convection is also guesstimated on a final-analysis, steady-state basis (basically lerping between external temperature and pure radiative-balance temperature based on atmospheric density). This supports callbacks to parts using various interfaces.

Returns

< show 0s when in analytic

< get incoming radiation

< fourth power

< get solar flux

< get flux from albedo and emissivity of current body

< Handle callbacks

< find resting temperature.

< lerp between it and ambient

< now apply it

< fourth power

< apply it.

virtual double FlightIntegrator.CalculateAreaExposed ( Part  part)
inlineprotectedvirtual
virtual double FlightIntegrator.CalculateAreaRadiative ( Part  part)
inlineprotectedvirtual
double FlightIntegrator.CalculateAtmosphericDensity ( double  pres,
double  temp 
)
inlineprotected
virtual double FlightIntegrator.CalculateBackgroundRadiationTemperature ( double  ambientTemp)
inlineprotectedvirtual

This is the temperature of background radiation yields correct value for sea level in Earth atmosphere, more or less other values are my best guess. Uses the densityThermalLerp

Parameters
ambientTemp
Returns
virtual void FlightIntegrator.CalculateConstantsAtmosphere ( )
inlineprotectedvirtual

Calculate the basic constants (pressure, density, solar flux, etc) when in atmosphere. Does solar air mass calcs, applies atmosphere temperature offset, calculates shock temp and convection stats, etc.

< Get/set aero stats

< compute lerp between the two modes of convection (also used to calculate shock temperature)

< compute external (shock) temperature, as distinct from static ambient temperature

< set convective heat transfer coefficient

< to be multiplied by a part's dimension later. Maybe. Probably not.

virtual void FlightIntegrator.CalculateConstantsVacuum ( )
inlineprotectedvirtual

Calculate the basic constants (pressure, density, solar flux, etc) when in vacuum

< no atmosphere to change solar flux

virtual double FlightIntegrator.CalculateConvectiveCoefficient ( )
inlineprotectedvirtual

Calculates a convective coefficient, for convective transfer = coeff * area * (air temp - skin temp) Handles the splashed case, then if in air lerps between Newtonian and Mach (Hypersonic) convection based on the Newtonian-Mach lerp and the craft's Mach number.

Returns
virtual double FlightIntegrator.CalculateConvectiveCoefficient ( Vessel.Situations  situation)
inlineprotectedvirtual

Calculates a convective coefficient, for convective transfer = coeff * area * (air temp - skin temp) Handles the splashed case, then if in air lerps between Newtonian and Mach (Hypersonic) convection based on the Newtonian-Mach lerp and the craft's Mach number.

Parameters
useSituationSet true will use the vessel situation (splashed or not). Otherwise will calc as if not splashed.
Returns

< else calculate both and lerp

virtual double FlightIntegrator.CalculateConvectiveCoefficientMach ( )
inlineprotectedvirtual

Calculate high-speed convective coefficient. Simple function of const * dnesity^exponent * spd^exponent (the exponents differ)

Returns
virtual double FlightIntegrator.CalculateConvectiveCoefficientNewtonian ( )
inlineprotectedvirtual

Calcuklate a coefficient for simple Newtonian convection Coeff ~= (density>1, density, else dnesity^exponent) * (base + spd^exponent)

Returns
virtual double FlightIntegrator.CalculateDensityThermalLerp ( )
inlinevirtual

Calculates a lerp value for use in determining background radiation temp and for steady-state temperatures w.r.t convection in analytic mode. NOTE: Uses the post-shockwave density, not the static density

Returns
virtual double FlightIntegrator.CalculateDragValue ( Part  part)
inlineprotectedvirtual
virtual double FlightIntegrator.CalculateDragValue_Conic ( Part  part)
inlineprotectedvirtual
virtual double FlightIntegrator.CalculateDragValue_Cube ( Part  part)
inlineprotectedvirtual
virtual double FlightIntegrator.CalculateDragValue_Cylindrical ( Part  part)
inlineprotectedvirtual
virtual double FlightIntegrator.CalculateDragValue_Spherical ( Part  part)
inlineprotectedvirtual
virtual void FlightIntegrator.CalculatePressure ( )
inlineprotectedvirtual
virtual double FlightIntegrator.CalculateShockTemperature ( )
inlinevirtual

Calculates the shock temperature given a velocity

Returns
virtual void FlightIntegrator.CalculateSunBodyFlux ( )
inlineprotectedvirtual

Calculates the distance to the sun, the solar flux, and the atmospheric temperature characterists and body albedo/emissive flux

< this does mean on the first frame we'll be in sunlight, but that's not a terrible assumption for the use cases we'll have.

void FlightIntegrator.CheckThermalGraph ( )
inlineprotected

Check and recreate thermal graph

void FlightIntegrator.DragCubeSetupAndPartAeroStats ( Vessel  v)
inlineprotected

< should be:

< (tonne/m^3 to kg/m^3, then to kPa from Pa, cancel)

< should be part vel-based, not vessel-based

virtual void FlightIntegrator.FixedUpdate ( )
inlineprotectedvirtual

Handle most physics integration

< double check for any vessel part changes in case events don't catch

< orbitdriver runs earlier now so SOI transition occurs at the start of frame not the end. Consistency!

< calculate pressure

< set vessel values

< done in Vessel.Awake - density = currentMainBody.GetDensity(staticPressurekPa, currentMainBody.GetTemperature(altitude));

< do this instead

virtual double FlightIntegrator.GetBodyArea ( PartThermalData  ptd)
inlinevirtual

Get radiative area facing the body

Parameters
ptd
Returns
override int FlightIntegrator.GetOrder ( )
inlinevirtual

Reimplemented from VesselModule.

float FlightIntegrator.GetPhysicslessChildMass ( Part  part)
inlineprotected

rewrite of the part method; this one accepts chains, and uses what we calculate in VesselPrecalculate

Parameters
part
Returns
virtual double FlightIntegrator.GetSunArea ( PartThermalData  ptd)
inlinevirtual

Get radiative area facing the sun

Parameters
ptd
Returns
virtual void FlightIntegrator.HookVesselEvents ( )
inlineprotectedvirtual
virtual void FlightIntegrator.Integrate ( Part  part)
inlineprotectedvirtual

Apply all forces to the part, both via the part's force list and from gravity (if done here not in Precalc) and from drag/bodylift. Also calculate angular drag both in air and submerged

Parameters
part
virtual void FlightIntegrator.IntegratePhysicalObjects ( List< physicalObject pObjs,
double  atmDensity 
)
inlineprotectedvirtual

Apply gravity and drag to physicalobjects

Parameters
pObjs
atmDensity

< Safety check

virtual void FlightIntegrator.OnDestroy ( )
inlineprotectedvirtual
void FlightIntegrator.OnDrawGizmosSelected ( )
inlineprotected
override void FlightIntegrator.OnLoadVessel ( )
inlinevirtual

Reimplemented from VesselModule.

void FlightIntegrator.OnPartEvent ( Part  part)
inlineprotected
void FlightIntegrator.OnPartEventFromToAction ( GameEvents.FromToAction< Part, Part data)
inlineprotected
void FlightIntegrator.OnPartEventTargetAction ( GameEvents.HostTargetAction< Part, Part data)
inlineprotected
override void FlightIntegrator.OnStart ( )
inlineprotectedvirtual

Reimplemented from VesselModule.

override void FlightIntegrator.OnUnloadVessel ( )
inlinevirtual

Reimplemented from VesselModule.

void FlightIntegrator.OnVesselEvent ( Vessel  vessel)
inlineprotected
virtual void FlightIntegrator.PrecalcConduction ( PartThermalData  ptd)
inlinevirtual

Sets the conduciton multiplier and skin-skin transfer multiplier for a PTD The latter starts from sqrt(radiative area) and then tries to take the relative areas of exposed and unexposed skin into account, i.e. it's maximal when about half is exposed and half unexposed

Parameters
ptd

< get circumference, basically

virtual void FlightIntegrator.PrecalcConvection ( PartThermalData  ptd)
inlinevirtual

Determine the final convective coefficient based on occlusion and convective stats

Parameters
ptd

< calculate convection

< W to kW, scalars

virtual void FlightIntegrator.PrecalcRadiation ( PartThermalData  ptd)
inlinevirtual

Precalc radiative stats like final coefficients and the final background rad temp exposed and unexposed. This is complicated because we need to figure out what portion of sun and body flux each apply to exposed and to unexposed skin (this is done by taking the dot of the sun vector vs the velocity vector and the -upaxis and the velocity vector respectively). All these get stored as incoming fluxes, since they are constant given a position and orientation and so needn't be recalculated during all the RK2 steps.

Parameters
ptd

< shared scalar

< W to kW

< shielding section

< sun flux

< do we have to deal with separate skin temps?

< do we have to deal with separate skin temps?

virtual void FlightIntegrator.SetSkinProperties ( PartThermalData  ptd)
inlinevirtual

Sets the basic skin properties for this thermal pass. Calculate the total area, the fraction of which is exposed or unexposed, and handle any transfers in thermal energy when those areas change.

Parameters
ptd

< set base area properties

< get exposed, if so area, set ptd data

< keep in sync

< will be negative

virtual void FlightIntegrator.SetSkinThermalMass ( Part  part)
inlinevirtual

Determine skin thermal mass from radiative area and part dry mass

Parameters
part

< this thermal mass will be subtracted from part thermal mass next tick.

virtual void FlightIntegrator.Setup ( )
inlinevirtual

< save from prefab, load on part.

< would be done soon anyway, but let's do it now.

override bool FlightIntegrator.ShouldBeActive ( )
inlinevirtual

Reimplemented from VesselModule.

virtual void FlightIntegrator.SmoothVelocity ( )
inlineprotectedvirtual

Smooth velocity so frame shifts are not passed on to aero/thermo integration

< First, detect spikes

< are we in a spike?

< >100G is probably a frame spike

< replace the old one too

< reset spike detection

< Calculate the smoothed velocity

virtual void FlightIntegrator.ThermalIntegrationPass ( bool  averageWithPrevious)
inlinevirtual

The actual thermal integration pass. First update conduction (this merely establishes fluxes). Then loop through all PTDs. Store previous temps if we're doing RK2 passes, then calculte convection and radiation for the part. Finally apply the fluxes.

Parameters
averageWithPreviousIs this the second step of an RK2 pass

< calculate convection

< calculate radiation

< Apply fluxes

< FIXME add skin conduction menu items

< DEBUG - log if we blow up.

virtual void FlightIntegrator.ThermoPrecalculate ( )
inlinevirtual

Any not-every-frame thermo calcs

virtual void FlightIntegrator.UnhookVesselEvents ( )
inlineprotectedvirtual
virtual void FlightIntegrator.UnifySkinTemp ( PartThermalData  ptd)
inlinevirtual

Unifies the exposed and unexposed skin temps into a unified temp using the whole skin thermal mass

Parameters
ptd
virtual void FlightIntegrator.Update ( )
inlinevirtual

Recalculate those bits that don't need to happen every frame (for now, the sun and body fluxes / air temperature offsets

virtual void FlightIntegrator.UpdateAerodynamics ( Part  part)
inlineprotectedvirtual

Updates the aerodyanmics stats of the part and also handles calculating submerged dynamic pressure and total angular drag.

Parameters
part

< detect rb

< set stuff to zero

< precalculate all the drag vector stuff

< sidestep a potential div by zero

virtual void FlightIntegrator.UpdateCompoundParts ( )
inlinevirtual

Apply thermal links based on compound parts

< us to target

virtual void FlightIntegrator.UpdateConduction ( )
inlinevirtual

The big one. Processes conduction across the vessel. Occurs in multiple passes. The first pass involves zeroing fluxes and getting unified skin temperatures. Then internal conduction happens (i.e. part internal <-> part internal, no skin). The PTDs are sorted by int temp, and then each PTD's links are checked. Heat pushes out to the links based on the conductive coefficient and the attach area. Checks are done to ensure stability. Since we start from hottest first, the hottest parts get priority flowing heat outwards. The same occurs for part skin <-> part skin conduction. Finally skin-skin conduction is computed for individual parts, between exposed and unexposed skin. Note that throughout this process only fluxes are stored.

< reset temporary vars

< figure out total system energy and store initial conductive fluxes.

< Now clamp the conduction.

< localInt is negative

< so tempDelta is negative

< half of internal

< when skin is not unified

< figure out total system energy and store initial conductive fluxes.

< the inside of a cargobay's skin doesn't count.

< fudge factor, to make up for contactArea<radArea and that conduction is the product of both conduction factors.

< local is negative

< so tempDelta is negative

virtual void FlightIntegrator.UpdateConvection ( PartThermalData  ptd)
inlinevirtual

Process convection in the simple flux = coeff * t_delta manner

Parameters
ptd
virtual void FlightIntegrator.UpdateMassStats ( )
inlineprotectedvirtual

Precalculate thermal mass and resource mass while finding CoM and Velocity.

< now Subtract skin thermal mass, then calculate recip

virtual void FlightIntegrator.UpdateOcclusion ( bool  all)
inlineprotectedvirtual
void FlightIntegrator.UpdateOcclusionBody ( )
inlineprotected

< update data according to projection vector

< Ensure sorted ascending

< clear cone list and add a cone for our leading part

< for every remaining part..

< initially not occluded

< check against all cones..

< just for sanity

void FlightIntegrator.UpdateOcclusionConvection ( )
inlineprotected

< reset multipliers

< update data according to projection vector (velocity)

< Ensure sorted ascending

< this is the maximum wedge angle at a given mach for an attached shock. If angle > this, detached.

< a decent approximation

< clear cone list and add a cone for our leading part

< Apply angle to FX shocks based on leading part angle.

< for every remaining part..

< initially not occluded

< check against all cones..

< just for sanity

void FlightIntegrator.UpdateOcclusionSolar ( )
inlineprotected

< update data according to projection vector

< Ensure sorted ascending

< clear cone list and add a cone for our leading part

< for every remaining part..

< initially not occluded

< check against all cones..

< just for sanity

virtual void FlightIntegrator.UpdateRadiation ( PartThermalData  ptd)
inlinevirtual

Apply incoming fluxes to part radiative fluxes and also calculate outgoing rad flux based on black-body radiation.

Parameters
ptd

< will not be used unless wasExposed = true

< after precalcing, we get the actual BRT each pass.

< Radiative flux = S-Bconst*e*A * (T^4 - radInT^4)

virtual void FlightIntegrator.UpdateThermalGraph ( )
inlineprotectedvirtual

Rebuilds the thermal graph. This involves recreating all PTDs and PTLs, cleaing and recreating occluders, reapplying old settings on the new PTDs, and finally registering the various callback interfaces.

< update the drag occlusion

< set skin temps if we had them before

< resize occluder arrays

virtual void FlightIntegrator.UpdateThermodynamics ( )
inlineprotectedvirtual

Main thermo method. First decides whether to run an analytic pass based off the last time a thermo pass was run (so when an unloaded vessel is loaded, analytic is run with the whole unloaded time, not just the current fixed frame time. If analytic, then that temp is applied, following any callbacks. If not, then all fluxes are zeroed and temps sanified, and then each of the Precalculate methods are run (for conduction, convection, and radiation). Finally some number of thermal integration paasses are run, either one pass using RK1 or a set of RK2 passes.

< i.e. set to analytic temp, period.

< twice the analytic min for unloaded.

< FIXME this will slightly speed things up at high rates.

< see above.

< clamp first, so Lerp doesn't have to.

< catch things that spawn with no set temperature, like asteroids

< only need to do this once, since mach and velocity vector are constant over thermal loop.

< Apply added fluxes.

< run each pass

Member Data Documentation

FlightIntegrator FlightIntegrator.ActiveVesselFI = null
static
double FlightIntegrator.altitude

Vessel velocity members.

double FlightIntegrator.atmosphereTemperatureOffset

based on latitude, sun angle, etc.

double FlightIntegrator.atmosphericTemperature
double FlightIntegrator.backgroundRadiationTemp
double FlightIntegrator.backgroundRadiationTempExposed
double FlightIntegrator.bodyAlbedoFlux

in kW/m^2

double FlightIntegrator.bodyEmissiveFlux

in kW/m^2

Vector3 FlightIntegrator.CoM
Vector3d FlightIntegrator.CoMd
List<CompoundPart> FlightIntegrator.compoundParts

We have to keep track of compound parts specially

int FlightIntegrator.compoundPartsTimer = 0
double FlightIntegrator.convectiveCoefficient
double FlightIntegrator.convectiveMachFlux
double FlightIntegrator.convectiveMachLerp
CelestialBody FlightIntegrator.currentMainBody
protected

Used to prevent calculating external temperature several times before fixedUpdate is called in the flightIntegrator (i.e. if more than one part tries to in the same frame)

double FlightIntegrator.deltaTime = 0d
protected
double FlightIntegrator.density
double FlightIntegrator.densityThermalLerp
protected
double FlightIntegrator.dynamicPressurekPa
double FlightIntegrator.externalTemperature
double FlightIntegrator.fDeltaTime
protected
double FlightIntegrator.fDeltaTimeRecip
protected
bool FlightIntegrator.firstFrame = true
double FlightIntegrator.fTimeSinceThermo = 0d
protected
double FlightIntegrator.fTimeSinceThermoRecip
protected
Vector3 FlightIntegrator.GraviticAcceleration
Transform FlightIntegrator.integratorTransform
protected
bool FlightIntegrator.isAnalytical = false

Are we in Analytic mode?

bool FlightIntegrator.isKerbal = false
bool FlightIntegrator.isRunning = false
const double FlightIntegrator.KPA2ATM = 1d / 101.325d
protected
Vector3 FlightIntegrator.lastVel
protected
int FlightIntegrator.lastVelIndex
protected
bool FlightIntegrator.lastVelProvisional = false
protected
double FlightIntegrator.mach
double FlightIntegrator.maxVelDeltaSqr = 1000d * 1000d
protected

Vessel stats.

bool FlightIntegrator.needOcclusion = true

Solar, Body.

OcclusionCylinder [] FlightIntegrator.occludersBody
int FlightIntegrator.occludersBodyCount
OcclusionCone [] FlightIntegrator.occludersConvection
int FlightIntegrator.occludersConvectionCount
OcclusionCylinder [] FlightIntegrator.occludersSun
int FlightIntegrator.occludersSunCount
List<IAnalyticOverheatModule> FlightIntegrator.overheatModules = new List<IAnalyticOverheatModule>()
protected

list of IAnalyticOverheatModule for analytic callbacks

int FlightIntegrator.partCount = 0
protected
Part FlightIntegrator.partRef
protected
int FlightIntegrator.partThermalDataCount = 0
protected
List<PartThermalData> FlightIntegrator.partThermalDataList = new List<PartThermalData>()

The set of PTDs, one per part with nonzero thermal mass. This is sorted by internal temp

List<PartThermalData> FlightIntegrator.partThermalDataListSkin = new List<PartThermalData>()

Same set of PTDs, sorted by skin temp

int FlightIntegrator.passes = 0
double FlightIntegrator.passesRecip = 1d
protected
List<IAnalyticPreview> FlightIntegrator.previewModules = new List<IAnalyticPreview>()
protected

List of preview modules for analytic callbakcs

double FlightIntegrator.pseudoReDragMult = 1d
double FlightIntegrator.pseudoReLerpTimeMult = 1d
double FlightIntegrator.pseudoReynolds
double FlightIntegrator.realDistanceToSun
bool FlightIntegrator.recreateThermalGraph = true
protected
bool FlightIntegrator.setupRun = false
protected
double FlightIntegrator.solarAirMass

solar air mass multiplier

double FlightIntegrator.solarFlux
double FlightIntegrator.solarFluxMultiplier

reduction to solar flux due to atmospheric absorption/scattering/etc

double FlightIntegrator.spd
double FlightIntegrator.staticPressureAtm
double FlightIntegrator.staticPressurekPa
CelestialBody FlightIntegrator.sunBody
static
double FlightIntegrator.sunDot

dot between terrain surface normal and sun.

int FlightIntegrator.sunLayerMask
staticprotected
Vector3 FlightIntegrator.sunVector

the vector to the sun

double FlightIntegrator.timeFactor = 0.02d
protected
double FlightIntegrator.timeSinceLastUpdate = 0d
int FlightIntegrator.VelIndex = 0
protected
Vector3 [] FlightIntegrator.VelSmoother
protected
int FlightIntegrator.VelSmoothLen = 10
staticprotected
double FlightIntegrator.VelSmoothLenRecip
protected
bool FlightIntegrator.VelSpiking = false
protected
bool FlightIntegrator.wasMachConvectionEnabled = false
protected

The documentation for this class was generated from the following file: