public void SetInitialState(InitialCondition ic) { SeaLevelRadius = ic.SeaLevelRadiusFtIC; RunwayRadius = SeaLevelRadius; // Set the position lat/lon/radius VState.vLocation = new Location(ic.LongitudeRadIC, ic.LatitudeRadIC, ic.AltitudeFtIC + ic.SeaLevelRadiusFtIC); // Set the Orientation from the euler angles VState.vQtrn = new Quaternion(ic.GetPhiRadIC(), ic.GetThetaRadIC(), ic.GetPsiRadIC()); // Set the velocities in the instantaneus body frame VState.vUVW = new Vector3D(ic.UBodyFpsIC, ic.VBodyFpsIC, ic.WBodyFpsIC); // Set the angular velocities in the instantaneus body frame. VState.vPQR = new Vector3D(ic.PRadpsIC, ic.QRadpsIC, ic.RRadpsIC); // Compute some derived values. vVel = VState.vQtrn.GetInverseTransformationMatrix() * VState.vUVW; // Finaly make shure that the quaternion stays normalized. VState.vQtrn.Normalize(); // Recompute the RunwayRadius level. RecomputeRunwayRadius(); }
/// <summary> /// Задает значения по умолчанию (значения по варианту). /// </summary> private void DefaultValues_Click(object sender, EventArgs e) { RangeFrom = 0; RangeFromTextBox.Text = RangeFrom.ToString(); RangeFromChecked = true; RangeTo = 0.05; RangeToTextBox.Text = RangeTo.ToString(); RangeToChecked = true; StepNumber = 100; StepNumberTextBox.Text = StepNumber.ToString(); StepNumberChecked = true; InitialCondition = 0; InitialConditionTextBox.Text = InitialCondition.ToString(); InitialConditionChecked = true; Resistance = 1000; ResistanceTextBox.Text = Resistance.ToString(); ResistanceChecked = true; Capacity = Math.Pow(10, -5); CapacityTextBox.Text = Capacity.ToString(); CapacityChecked = true; Voltage = 10; VoltageTextBox.Text = Voltage.ToString(); VoltageChecked = true; }
public void Initialize(InitialCondition initialCondition) { title.text = $"Set {ConditionsController.active.conditionViews.Count}"; SetInitialConditionUIValues(initialCondition); presets.ClearOptions(); List <Dropdown.OptionData> options = new List <Dropdown.OptionData>(); options.Add(new Dropdown.OptionData("-")); foreach (string key in ConditionsController.active.initialConditionsPresets.Keys) { options.Add(new Dropdown.OptionData(key)); } presets.AddOptions(options); int j = 0; int presetValue = 0; foreach (string key in ConditionsController.active.initialConditionsPresets.Keys) { if (AreInitialConditionsEquals(ConditionsController.active.initialConditionsPresets[key], initialCondition)) { presetValue = j + 1; } j++; } // Debug.Log(initialCondition.angularVelocity == ConditionsController.active.initialConditionsPresets["Rotating Disc"].angularVelocity); presets.value = presetValue; }
public void CheckOrientation() { string test = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- This file sets up the mk82 to start off from altitude. --> <ubody unit=""FT/SEC""> 100.0 </ubody> <alpha unit=""DEG""> 10.0 </alpha> <beta unit=""DEG""> 20.0 </beta> </initialize>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elem = BuildXmlConfig(test); InitialCondition IC = fdm.GetIC(); IC.Load(elem, false); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim Initial Conditions: Orientation"); } //Checks values Assert.AreEqual(92.541657839832311, IC.GetUBodyFpsIC(), tolerance); Assert.AreEqual(10.0, IC.GetAlphaDegIC(), tolerance, "initial angle of attack"); Assert.AreEqual(20.0, IC.GetBetaDegIC(), tolerance, "initial sideslip angle"); }
/// <summary> /// Get constant values /// </summary> public void CalculateCollocationPointsConstants() { foreach (var area in this.Areas) { double denominator1 = InitialCondition.denominator1(area.configurationData.GetDiffusionCoefficient(), area.configurationData.iterationProcess.TimeStep); double denominator2 = InitialCondition.denominator2(area.configurationData.GetDiffusionCoefficient(), area.configurationData.iterationProcess.TimeStep); foreach (var segment in area.Segments) { Parallel.ForEach(segment.CollocationPoints, (collPoint) => { foreach (var innerSurface in area.Surfaces) { foreach (var innerSurfaceIntegrationPoint in innerSurface.InitialConditionSurfaceIntegrationPoints) { if (area.configurationData.arePropertiesTimeDependent()) { denominator1 = InitialCondition.denominator1(area.configurationData.GetDiffusionCoefficient(innerSurfaceIntegrationPoint.TemperatureValue), area.configurationData.iterationProcess.TimeStep); denominator2 = InitialCondition.denominator2(area.configurationData.GetDiffusionCoefficient(innerSurfaceIntegrationPoint.TemperatureValue), area.configurationData.iterationProcess.TimeStep); } collPoint.SurfaceIntegrationPointsInitialConditionConstantValues.Add(InitialCondition.CalculateSiglePointFunctionValue(collPoint.RealPosition, denominator1, denominator2, innerSurfaceIntegrationPoint)); } } }); } } }
public void CheckVelocity() { string test = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- This file sets up the mk82 to start off from altitude. --> <ubody unit=""FT/SEC""> 10.0 </ubody> <vbody unit=""FT/SEC""> 20.0 </vbody> <wbody unit=""FT/SEC""> 30.0 </wbody> </initialize>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elem = BuildXmlConfig(test); InitialCondition IC = fdm.GetIC; IC.Load(elem, false); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim Initial Conditions: Velocity"); } //Checks values Assert.AreEqual(100.0, IC.UBodyFpsIC); Assert.AreEqual(200.0, IC.VBodyFpsIC); Assert.AreEqual(300.0, IC.WBodyFpsIC); }
public void CheckOrientation() { string test = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- This file sets up the mk82 to start off from altitude. --> <alpha unit=""DEG""> 10.0 </alpha> <beta unit=""DEG""> 20.0 </beta> <theta unit=""DEG""> 30.0 </theta> <phi unit=""DEG""> 40.0 </phi> </initialize>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elem = BuildXmlConfig(test); InitialCondition IC = fdm.GetIC; IC.Load(elem, false); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim Initial Conditions: Orientation"); } //Checks values Assert.AreEqual(10.0, IC.AlphaDegIC, "initial angle of attack"); Assert.AreEqual(20.0, IC.BetaDegIC, "initial sideslip angle"); Assert.AreEqual(30.0, IC.ThetaDegIC, "initial pitch angle"); }
public void CheckPosition() { string test = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- This file sets up the mk82 to start off from altitude. --> <latitude unit=""DEG""> 47.0 </latitude> <longitude unit=""DEG"">-110.0 </longitude> <altitude unit=""FT""> 10000.0 </altitude> </initialize>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elem = BuildXmlConfig(test); InitialCondition IC = fdm.GetIC; IC.Load(elem, false); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim Initial Conditions: Lat, long, alt."); } //Checks values Assert.AreEqual(47.0, IC.LatitudeDegIC, "latitude in deg."); Assert.AreEqual(-110.0, IC.LongitudeDegIC, "longitude in deg."); Assert.AreEqual(10000.0, IC.AltitudeFtIC, "Altitude in Ft"); }
private void LoadAndRunModel(string modelFileName) { FDMExecutive fdm = new FDMExecutive(); fdm.AircraftPath = rootDirectory + "/aircraft"; fdm.EnginePath = rootDirectory + "/engine"; fdm.LoadModel(modelFileName, true); InitialCondition IC = fdm.GetIC; IC.Load("reset00", true); Trim fgt = new Trim(fdm, TrimMode.Full); if (!fgt.DoTrim()) { log.Debug("Trim Failed"); } fgt.Report(); bool result = fdm.Run(); int count = 0; while (result && !(fdm.Holding() || fdm.State.IsIntegrationSuspended)) { result = fdm.Run(); count++; if (count > 10 && log.IsDebugEnabled) { count = 0; log.Debug("=> Time: " + fdm.State.SimTime); } } }
public double GetResultsArea(RealPoint point) { double result = 0.0; foreach (var area in this.Areas) { foreach (var segmentI in area.Segments) { int i = 0; foreach (var collPointI in segmentI.CollocationPoints) { var functionT = Function_T.CalculateAreaValue(point, segmentI, collPointI, area.configurationData); var functionq = Function_q.CalculateAreaValue(point, segmentI, collPointI, area.configurationData); result += -functionq * segmentI.TemperatureBoundaryCondition.BoundaryConditionVector[i] + functionT * segmentI.HeatFluxBoundaryCondition.BoundaryConditionVector[i]; i++; } } } foreach (var area in this.Areas) { var initial = InitialCondition.CalculateValue(area, point); result += initial; if (area.configurationData.addHeatSource) { var subAreaIntegrationHelper = new SubAreaIntegrationHelper(4, area.Surfaces.Select(x => x.SurfaceShape).ToList()); result += HeatSource.CalculateValue(area, point, subAreaIntegrationHelper); } } return(result); }
public void CheckOrientation02() { string test = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- This file sets up the ball in orbit. Velocity of Earth surface at equator: 1525.92 ft/sec. at ground level. Velocity of Earth surface-synchronous point at equator: 1584.26 ft/sec. at 800 kft. 1584.2593825 + 23869.9759596 = 25454.235342 ft/sec --> <ubody unit=""FT/SEC""> 23869.9759596 </ubody> <latitude unit = ""DEG"" > 0.0 </latitude> <longitude unit = ""DEG"" > 0.0 </longitude> <psi unit = ""DEG"" > 90.0 </psi> <altitude unit = ""FT"" > 800000.0 </altitude> </initialize>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elem = BuildXmlConfig(test); InitialCondition IC = fdm.GetIC(); IC.Load(elem, false); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim Initial Conditions: Orientation"); } //Checks values Assert.AreEqual(23869.9759596, IC.GetUBodyFpsIC(), tolerance); Assert.AreEqual(90.0, IC.GetPsiDegIC(), tolerance, "initial heading angle"); }
public void TestDefaultConstructor() { FDMExecutive fdmex = new FDMExecutive(); InitialCondition ic = new InitialCondition(fdmex); Assert.AreEqual(0.0, ic.GetLatitudeDegIC()); Assert.AreEqual(0.0, ic.GetLatitudeRadIC()); Assert.AreEqual(0.0, ic.GetLongitudeDegIC()); Assert.AreEqual(0.0, ic.GetLongitudeRadIC()); Assert.AreEqual(0.0, ic.GetGeodLatitudeDegIC()); Assert.AreEqual(0.0, ic.GetGeodLatitudeRadIC()); Assert.AreEqual(0.0, ic.GetThetaDegIC()); Assert.AreEqual(0.0, ic.GetThetaRadIC()); Assert.AreEqual(0.0, ic.GetPhiDegIC()); Assert.AreEqual(0.0, ic.GetPhiRadIC()); Assert.AreEqual(0.0, ic.GetPsiDegIC()); Assert.AreEqual(0.0, ic.GetPsiRadIC()); Assert.AreEqual(0.0, ic.GetAltitudeASLFtIC()); Assert.AreEqual(0.0, ic.GetAltitudeAGLFtIC()); Assert.AreEqual(0.0, ic.GetEarthPositionAngleIC()); Assert.AreEqual(0.0, ic.GetTerrainElevationFtIC()); Assert.AreEqual(0.0, ic.GetVcalibratedKtsIC()); Assert.AreEqual(0.0, ic.GetVequivalentKtsIC()); Assert.AreEqual(0.0, ic.GetVgroundFpsIC()); Assert.AreEqual(0.0, ic.GetVtrueFpsIC()); Assert.AreEqual(0.0, ic.GetMachIC()); Assert.AreEqual(0.0, ic.GetClimbRateFpsIC()); Assert.AreEqual(0.0, ic.GetFlightPathAngleDegIC()); Assert.AreEqual(0.0, ic.GetFlightPathAngleRadIC()); Assert.AreEqual(0.0, ic.GetAlphaDegIC()); Assert.AreEqual(0.0, ic.GetAlphaRadIC()); Assert.AreEqual(0.0, ic.GetBetaDegIC()); Assert.AreEqual(0.0, ic.GetBetaDegIC()); Assert.AreEqual(0.0, ic.GetBetaRadIC()); Assert.AreEqual(0.0, ic.GetWindFpsIC()); Assert.AreEqual(0.0, ic.GetWindDirDegIC()); Assert.AreEqual(0.0, ic.GetWindUFpsIC()); Assert.AreEqual(0.0, ic.GetWindVFpsIC()); Assert.AreEqual(0.0, ic.GetWindWFpsIC()); Assert.AreEqual(0.0, ic.GetWindNFpsIC()); Assert.AreEqual(0.0, ic.GetWindEFpsIC()); Assert.AreEqual(0.0, ic.GetWindDFpsIC()); Assert.AreEqual(0.0, ic.GetUBodyFpsIC()); Assert.AreEqual(0.0, ic.GetVBodyFpsIC()); Assert.AreEqual(0.0, ic.GetWBodyFpsIC()); Assert.AreEqual(0.0, ic.GetVNorthFpsIC()); Assert.AreEqual(0.0, ic.GetVEastFpsIC()); Assert.AreEqual(0.0, ic.GetVDownFpsIC()); Assert.AreEqual(0.0, ic.GetPRadpsIC()); Assert.AreEqual(0.0, ic.GetQRadpsIC()); Assert.AreEqual(0.0, ic.GetRRadpsIC()); // TS_ASSERT_VECTOR_EQUALS(ic.GetWindNEDFpsIC(), zero); //TS_ASSERT_VECTOR_EQUALS(ic.GetUVWFpsIC(), zero); //TS_ASSERT_VECTOR_EQUALS(ic.GetPQRRadpsIC(), zero); }
public void Add(InitialCondition initialCondition) { GameObject instance = Instantiate(conditionPrefab, conditionInstanceParent); instance.SetActive(true); ConditionView conditionView = instance.GetComponent <ConditionView>(); conditionViews.Add(conditionView); conditionView.Initialize(initialCondition); }
public void CheckOrientationAttributes() { string testIC = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- some comments. --> <alpha unit=""DEG""> 10.0 </alpha> <beta unit=""DEG""> 20.0 </beta> <theta unit=""DEG""> 30.0 </theta> <phi unit=""DEG""> 40.0 </phi> <psi unit=""DEG""> 50.0 </psi> </initialize>"; string testProperties = @"<?xml version=""1.0""?> <?xml-stylesheet href=""JSBSim.xsl"" type=""application/xml""?> <function NAME=""aero/coefficient/ClDf2""> <sum> <property>ic/alpha-deg</property> <property>ic/beta-deg</property> <property>ic/theta-deg</property> <property>ic/phi-deg</property> <property>ic/psi-true-deg</property> </sum> </function>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elemIc = BuildXmlConfig(testIC, "initialize"); InitialCondition IC = fdm.GetIC; IC.Load(elemIc, false); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim IC InputOutput: Orientation Attributes."); } //Checks values Assert.AreEqual(10.0, IC.AlphaDegIC, tolerance, "Cheking Alpha in deg. If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); Assert.AreEqual(20.0, IC.BetaDegIC, tolerance, "Cheking Beta in deg. If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); Assert.AreEqual(30.0, IC.ThetaDegIC, tolerance, "Cheking Theta in deg. If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); Assert.AreEqual(40.0, IC.PhiDegIC, tolerance, "Cheking Phi in deg. If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); Assert.AreEqual(50.0, IC.PsiDegIC, tolerance, "Cheking Psi in deg. If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); XmlElement elemFunction = BuildXmlConfig(testProperties, "function"); Function func = new Function(fdm, elemFunction); //Checks InputOutput Assert.AreEqual(IC.AlphaDegIC + IC.BetaDegIC + IC.ThetaDegIC + IC.PhiDegIC + IC.PsiDegIC, func.GetValue(), tolerance); }
public void DropdownUpdate() { string key = presets.options[presets.value].text; if (!ConditionsController.active.initialConditionsPresets.ContainsKey(key)) { return; } InitialCondition initialCondition = ConditionsController.active.initialConditionsPresets[key]; SetInitialConditionUIValues(initialCondition); }
public double GetTemperatureFromSurfaceIntegrationPointConstants(SurfaceIntegrationPoint point) { double result = 0.0; int j = 0; foreach (var area in this.Areas) { foreach (var segment in area.Segments) { foreach (var collPoint in segment.CollocationPoints) { result += -point.FunctionqConstantValue[j] * segment.TemperatureBoundaryCondition.BoundaryConditionVector[collPoint.Index] + point.FunctionTConstantValue[j] * segment.HeatFluxBoundaryCondition.BoundaryConditionVector[collPoint.Index]; j++; } } } int k = 0; foreach (var area in this.Areas) { //To tradycyjnie result += InitialCondition.CalculateValue(area, point.RealPosition); //To w przypadku przechowywania parametrów //foreach (var surface in this.Surfaces) //{ // foreach (var surfaceIntegrationPoint in surface.SurfaceIntegrationPoints) // { // value += point.InitialConditionConstantValues[k] * surfaceIntegrationPoint.TemperatureValue; // k++; // } //} if (area.configurationData.addHeatSource) { if (area.configurationData.isHeatSourceTimeDependent) { var subAreaIntegrationHelper = new SubAreaIntegrationHelper(4, area.Surfaces.Select(x => x.SurfaceShape).ToList()); result += HeatSource.CalculateValue(area, point.RealPosition, subAreaIntegrationHelper); } else { result += point.HeatSourceConstantValue; } } } return(result); }
public List <Area> CalculateIterationForMultipleAreas() { foreach (var area in this.Problem.Areas) { area.calculateVariableBoundaryConditions(); area.CalculateBoundaryTemperature(); } int j = 0; foreach (var area in this.Problem.Areas) { var areaVector = area.GetKnownBoundaryVector(); foreach (var value in areaVector) { this.vectorF[j++] = value; } } if (Problem.IterationProcess.CurrentIteration == 1 || this.Problem.Areas[0].configurationData.arePropertiesTimeDependent()) { BuildMatrixesForMultipleAreas(); } if (Problem.IterationProcess.CurrentIteration == 1) { Problem.CalculateCollocationPointsConstants(); Problem.CalculateSurfaceIntegrationPointsConstants(); } this.SeparateKnownFromUnknownForMultipleAreas(); this.CalculateKnownVectorForMultipleAreas(); j = 0; foreach (var area in this.Problem.Areas) { var areaVector = InitialCondition.CalculateBoundaryVector(area); foreach (var value in areaVector) { this.initialCondition[j++] = value; } } this.AddInitialConditionForMultipleAreas(); this.SolveEquations(); this.SetUnknownBoundaryConditionsForMultipleAreas(); return(this.Problem.Areas); }
public void CheckLoadInitCond_MK82() { FDMExecutive fdm = new FDMExecutive(); fdm.AircraftPath = "../../../Models/aircraft"; fdm.EnginePath = "../../../Models/engine"; InitialCondition IC = fdm.GetIC; fdm.LoadModel(aircraft_MK82, true); IC.Load("reset00", true); Assert.AreEqual(aircraft_MK82, fdm.ModelName); Assert.AreEqual("MK-82", fdm.Aircraft.AircraftName); }
private void TestICProperties_Click(object sender, System.EventArgs e) { string testIC = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- This file sets up the mk82 to start off from altitude. <latitude unit=""DEG""> 3.0 </latitude> <longitude unit=""DEG""> 7.0 </longitude> <altitude unit=""FT""> 9.0 </altitude> --> <ubody unit=""FT/SEC""> 400.0 </ubody> <vbody unit=""FT/SEC""> 0.0 </vbody> <wbody unit=""FT/SEC""> 120.0 </wbody> </initialize>"; string testProperties = @"<?xml version=""1.0""?> <?xml-stylesheet href=""JSBSim.xsl"" type=""application/xml""?> <function NAME=""aero/coefficient/ClDf2""> <sum> <property>ic/lat-gc-deg</property> <property>ic/lat-gc-deg</property> <property>ic/lat-gc-deg</property> </sum> </function>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elemIc = BuildXmlConfig(testIC, "initialize"); InitialCondition IC = fdm.GetIC; IC.Load(elemIc); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim IC InputOutput: Lat., Lon., Alt."); } XmlElement elemFunction = BuildXmlConfig(testProperties, "function"); JSBSim.MathValues.Function func = new JSBSim.MathValues.Function(fdm.PropertyManager, elemFunction); //Checks InputOutput log.Debug(" The value =" + IC.LatitudeDegIC + IC.LongitudeDegIC + IC.AltitudeFtIC + ", the func =" + func.GetValue()); }
/// <summary> /// Initializes the simulation state based on parameters from an Initial Conditions object. /// </summary> /// <param name="initCond">an initial conditions object.</param> public void Initialize(InitialCondition initCond) { sim_time = 0.0; FDMExec.Propagate.SetInitialState(initCond); FDMExec.Atmosphere.Run(); FDMExec.Atmosphere.SetWindNED(initCond.WindNFpsIC, initCond.WindEFpsIC, initCond.WindDFpsIC); Vector3D vAeroUVW; vAeroUVW = FDMExec.Propagate.GetUVW() + FDMExec.Propagate.GetTl2b() * FDMExec.Atmosphere.GetWindNED(); double alpha, beta; if (vAeroUVW.W != 0.0) { alpha = vAeroUVW.U * vAeroUVW.U > 0.0 ? Math.Atan2(vAeroUVW.W, vAeroUVW.U) : 0.0; } else { alpha = 0.0; } if (vAeroUVW.V != 0.0) { beta = vAeroUVW.U * vAeroUVW.U + vAeroUVW.W * vAeroUVW.W > 0.0 ? Math.Atan2(vAeroUVW.V, (Math.Abs(vAeroUVW.U) / vAeroUVW.U) * Math.Sqrt(vAeroUVW.U * vAeroUVW.U + vAeroUVW.W * vAeroUVW.W)) : 0.0; } else { beta = 0.0; } FDMExec.Auxiliary.SetAB(alpha, beta); double Vt = vAeroUVW.GetMagnitude(); FDMExec.Auxiliary.Vt = Vt; FDMExec.Auxiliary.Mach = Vt / FDMExec.Atmosphere.SoundSpeed; double qbar = 0.5 * Vt * Vt * FDMExec.Atmosphere.Density; FDMExec.Auxiliary.Qbar = qbar; }
public void CheckPositionAttributes() { string testIC = @"<?xml version=""1.0""?> <initialize name=""reset00""> <!-- some comments. --> <latitude unit=""DEG""> 3.0 </latitude> <longitude unit=""DEG""> 7.0 </longitude> <altitude unit=""FT""> 29.0 </altitude> </initialize>"; string testProperties = @"<?xml version=""1.0""?> <?xml-stylesheet href=""JSBSim.xsl"" type=""application/xml""?> <function NAME=""aero/coefficient/ClDf2""> <sum> <property>ic/lat-gc-deg</property> <property>ic/long-gc-deg</property> <property>ic/h-sl-ft</property> </sum> </function>"; FDMExecutive fdm = new FDMExecutive(); XmlElement elemIc = BuildXmlConfig(testIC, "initialize"); InitialCondition IC = fdm.GetIC; IC.Load(elemIc, false); if (log.IsDebugEnabled) { log.Debug("Testing JSBSim IC InputOutput: Lat., Lon., Alt."); } //Checks values Assert.AreEqual(3.0, IC.LatitudeDegIC, tolerance, "Cheking latitude in deg. If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); Assert.AreEqual(7.0, IC.LongitudeDegIC, tolerance, "Cheking Longitude in deg.If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); Assert.AreEqual(29.0, IC.AltitudeFtIC, tolerance, "Cheking Altitude in Ft.If you have an error, try to change USEJSBSIM in CommonUtils.MathLib.Constants"); XmlElement elemFunction = BuildXmlConfig(testProperties, "function"); Function func = new Function(fdm, elemFunction); //Checks InputOutput Assert.AreEqual(IC.LatitudeDegIC + IC.LongitudeDegIC + IC.AltitudeFtIC, func.GetValue(), tolerance); }
public void TestSetPositionAGL() { FDMExecutive fdmex = new FDMExecutive(); InitialCondition ic = new InitialCondition(fdmex); ic.SetTerrainElevationFtIC(2000.0); for (double lon = -180.0; lon <= 180.0; lon += 30.0) { ic.SetLongitudeDegIC(lon); // Altitude first, then latitude for (double agl = 1.0; agl <= 1000001.0; agl += 10000.0) { ic.SetAltitudeAGLFtIC(agl); for (double lat = -90.0; lat <= 90.0; lat += 10.0) { ic.SetLatitudeDegIC(lat); Assert.AreEqual(lon, ic.GetLongitudeDegIC(), tolerance * 100.0); Assert.AreEqual(lon * Math.PI / 180.0, ic.GetLongitudeRadIC(), tolerance); Assert.AreEqual(1.0, ic.GetAltitudeASLFtIC() / (agl + 2000.0), 2E-8); Assert.AreEqual(1.0, ic.GetAltitudeAGLFtIC() / agl, 2E-8); Assert.AreEqual(lat, ic.GetLatitudeDegIC(), tolerance * 10.0); Assert.AreEqual(lat * Math.PI / 180.0, ic.GetLatitudeRadIC(), tolerance); } } // Latitude first, then altitude for (double lat = -90.0; lat <= 90.0; lat += 10.0) { ic.SetLatitudeDegIC(lat); for (double agl = 1.0; agl <= 1000001.0; agl += 10000.0) { ic.SetAltitudeAGLFtIC(agl); Assert.AreEqual(lon, ic.GetLongitudeDegIC(), tolerance * 100.0); Assert.AreEqual(lon * Math.PI / 180.0, ic.GetLongitudeRadIC(), tolerance); Assert.AreEqual(1.0, ic.GetAltitudeASLFtIC() / (agl + 2000.0), 2E-8); Assert.AreEqual(1.0, ic.GetAltitudeAGLFtIC() / agl, 2E-8); Assert.AreEqual(lat, ic.GetLatitudeDegIC(), tolerance * 100.0); Assert.AreEqual(lat * Math.PI / 180.0, ic.GetLatitudeRadIC(), tolerance); } } } }
/// <summary> /// Initializes the simulation state based on parameters from an Initial Conditions object. /// </summary> /// <param name="initCond">an initial conditions object.</param> public void Initialize(InitialCondition initCond) { #if TODO sim_time = 0.0; FDMExec.Propagate.SetInitialState(initCond); FDMExec.Atmosphere.Run(false); FDMExec.Atmosphere.SetWindNED(initCond.WindNFpsIC, initCond.WindEFpsIC, initCond.WindDFpsIC); Vector3D vAeroUVW; vAeroUVW = FDMExec.Propagate.GetUVW() + FDMExec.Propagate.GetTl2b() * FDMExec.Atmosphere.GetWindNED(); double alpha, beta; if (vAeroUVW.W != 0.0) { alpha = vAeroUVW.U * vAeroUVW.U > 0.0 ? Math.Atan2(vAeroUVW.W, vAeroUVW.U) : 0.0; } else { alpha = 0.0; } if (vAeroUVW.V != 0.0) { beta = vAeroUVW.U * vAeroUVW.U + vAeroUVW.W * vAeroUVW.W > 0.0 ? Math.Atan2(vAeroUVW.V, (Math.Abs(vAeroUVW.U) / vAeroUVW.U) * Math.Sqrt(vAeroUVW.U * vAeroUVW.U + vAeroUVW.W * vAeroUVW.W)) : 0.0; } else { beta = 0.0; } FDMExec.Auxiliary.SetAB(alpha, beta); double Vt = vAeroUVW.GetMagnitude(); FDMExec.Auxiliary.Vt = Vt; FDMExec.Auxiliary.Mach = Vt / FDMExec.Atmosphere.SoundSpeed; double qbar = 0.5 * Vt * Vt * FDMExec.Atmosphere.Density; FDMExec.Auxiliary.Qbar = qbar; #endif throw new NotImplementedException("Pending upgrade to lastest version of JSBSIM"); }
public override void Execute(EventDescription token) { if (this.LastEvent != token) { var _input1 = InputNodes[0].Object; var _input2 = InputNodes[1].Object; if (_input1 != null && _input2 != null) { dynamic a = 0; dynamic b = 0; if (_input1.ToString().IsNumeric() && _input2.ToString().IsNumeric()) { a = double.Parse(_input1.ToString()); b = double.Parse(_input2.ToString()); OutputNodes[0].Object = DoOp(a, b); } else if (Utils.IsSignal(_input1) && Utils.IsSignal(_input2)) { var in1 = (OpenSignalLib.Sources.Signal)(Utils.AsSignal(_input1)); var in2 = (OpenSignalLib.Sources.Signal)(Utils.AsSignal(_input2)); var longest = (OpenSignalLib.Sources.Signal)Utils.SelectLongest(in1, in2); var shortest = (OpenSignalLib.Sources.Signal)Utils.SelectOther(in1, in2, longest); OpenSignalLib.Sources.Signal s = new OpenSignalLib.Sources.Signal(); s.Samples = new double[longest.Samples.Length]; s.SamplingRate = Math.Min(longest.SamplingRate, shortest.SamplingRate); for (int i = 0; i < shortest.Samples.Length; i++) { a = longest.Samples[i]; b = shortest.Samples[i]; s.Samples[i] = DoOp(a, b); } OutputNodes[0].Object = s; } else if (Utils.IsInitialCondition(_input1) || Utils.IsInitialCondition(_input2)) { InitialCondition inC = (InitialCondition)(Utils.IsInitialCondition(_input1) ? _input1 : _input2); object other = (Utils.IsInitialCondition(_input1) ? _input2 : _input1); if (Utils.IsSignal(other)) { OutputNodes[0].Object = Utils.AsSignal(other); } } } } }
public Area CalculateIterationForSingleArea() { this.Problem.Areas[0].calculateVariableBoundaryConditions(); this.Problem.Areas[0].CalculateBoundaryTemperature(); this.vectorF = this.Problem.Areas[0].GetKnownBoundaryVector(); if (this.Problem.IterationProcess.CurrentIteration == 1 || this.Problem.Areas[0].configurationData.arePropertiesTimeDependent()) { this.matrixT = Function_T.CalculateBoundaryMatrix(this.Problem.Areas[0]); this.matrixq = Function_q.CalculateBoundaryMatrix(this.Problem.Areas[0]); } if (Problem.IterationProcess.CurrentIteration == 1) { Problem.CalculateCollocationPointsConstants(); Problem.CalculateSurfaceIntegrationPointsConstants(); } this.SeparateKnownFromUnknownForSingleArea(); this.CalculateKnownVectorForSingleArea(); //To tradycyjnie this.initialCondition = InitialCondition.CalculateBoundaryVector(this.Problem.Areas[0]); //To w przypadku przechowywania parametrów //this.GetInitialConditionVectorFromCollocationPointsConstants(); this.AddInitialConditionForSingleArea(); if (this.Problem.Areas[0].configurationData.addHeatSource) { if (this.Problem.Areas[0].configurationData.isHeatSourceTimeDependent || this.Problem.IterationProcess.CurrentIteration == 1) { this.heatSource = HeatSource.CalculateBoundaryVector(this.Problem.Areas[0]); } this.AddHeatSource(); } this.SolveEquations(); this.SetUnknownBoundaryConditionsForSingleArea(); return(this.Problem.Areas[0]); }
private FDMExecutive LoadAndRunModel(string modelFileName, string IcFileName) { FDMExecutive fdm = new FDMExecutive(); fdm.AircraftPath = AircraftPath; fdm.EnginePath = EnginePath; fdm.LoadModel(modelFileName, true); InitialCondition IC = fdm.GetIC(); IC.Load(IcFileName, true); Trim fgt = new Trim(fdm, TrimMode.Full); if (!fgt.DoTrim()) { log.Debug("Trim Failed"); } fgt.Report(); bool result = fdm.Run(); int count = 0; while (result && !(fdm.Holding() || fdm.State.IsIntegrationSuspended) && count < 10000) { result = fdm.Run(); count++; if (count > 120 && log.IsDebugEnabled) { count = 0; log.Debug("Time: " + fdm.State.SimTime); } } log.Debug("Final Time: " + fdm.State.SimTime); return(fdm); }
void SetInitialConditionUIValues(InitialCondition initialCondition) { numberOfParticles.text = initialCondition.numberOfParticles.ToString(); centerX.text = initialCondition.center.x.ToString(); centerY.text = initialCondition.center.y.ToString(); centerZ.text = initialCondition.center.z.ToString(); radius.text = initialCondition.radius.ToString(); shapeElipsoidX.text = initialCondition.shapeElipsoid.x.ToString(); shapeElipsoidY.text = initialCondition.shapeElipsoid.y.ToString(); shapeElipsoidZ.text = initialCondition.shapeElipsoid.z.ToString(); turbulenceStrength.text = initialCondition.turbulenceStrength.ToString(); turbulenceElipsoidX.text = initialCondition.turbulenceElipsoid.x.ToString(); turbulenceElipsoidY.text = initialCondition.turbulenceElipsoid.y.ToString(); turbulenceElipsoidZ.text = initialCondition.turbulenceElipsoid.z.ToString(); angularVelocity.text = initialCondition.angularVelocity.ToString(); seed.text = initialCondition.seed.ToString(); }
bool AreInitialConditionsEquals(InitialCondition conditionA, InitialCondition conditionB) { return (conditionA.numberOfParticles == conditionB.numberOfParticles && conditionA.center.x == conditionB.center.x && conditionA.center.y == conditionB.center.y && conditionA.center.z == conditionB.center.z && conditionA.radius == conditionB.radius && conditionA.shapeElipsoid.x == conditionB.shapeElipsoid.x && conditionA.shapeElipsoid.y == conditionB.shapeElipsoid.y && conditionA.shapeElipsoid.z == conditionB.shapeElipsoid.z && conditionA.turbulenceStrength == conditionB.turbulenceStrength && conditionA.turbulenceElipsoid.x == conditionB.turbulenceElipsoid.x && conditionA.turbulenceElipsoid.y == conditionB.turbulenceElipsoid.y && conditionA.turbulenceElipsoid.z == conditionB.turbulenceElipsoid.z && conditionA.angularVelocity == conditionB.angularVelocity && conditionA.seed == conditionB.seed); }
private bool Allocate() { bool result = true; models = new Model[(int)eModels.eNumStandardModels]; // First build the inertial model since some other models are relying on // the inertial model and the ground callback to build themselves. // Note that this does not affect the order in which the models will be // executed later. models[(int)eModels.eInertial] = new Inertial(this); // See the eModels enum specification in the header file. The order of the // enums specifies the order of execution. The Models[] vector is the primary // storage array for the list of models. models[(int)eModels.ePropagate] = new Propagate(this); models[(int)eModels.eInput] = new Input(this); models[(int)eModels.eAtmosphere] = new StandardAtmosphere(this); models[(int)eModels.eWinds] = new Winds(this); models[(int)eModels.eSystems] = new FlightControlSystem(this); models[(int)eModels.eMassBalance] = new MassBalance(this); models[(int)eModels.eAuxiliary] = new Auxiliary(this); models[(int)eModels.ePropulsion] = new Propulsion(this); models[(int)eModels.eAerodynamics] = new Aerodynamics(this); models[(int)eModels.eGroundReactions] = new GroundReactions(this); //PENDING new JSBSIM models[(int)eModels.eExternalReactions] = new ExternalReactions(this); //PENDING new JSBSIM models[(int)eModels.eBuoyantForces] = new BuoyantForces(this); models[(int)eModels.eAircraft] = new Aircraft(this); models[(int)eModels.eAccelerations] = new Accelerations(this); models[(int)eModels.eOutput] = new Output(this); // Assign the Model shortcuts for internal executive use only. propagate = (Propagate)models[(int)eModels.ePropagate]; inertial = (Inertial)models[(int)eModels.eInertial]; atmosphere = (Atmosphere)models[(int)eModels.eAtmosphere]; winds = (Winds)models[(int)eModels.eWinds]; FCS = (FlightControlSystem)models[(int)eModels.eSystems]; massBalance = (MassBalance)models[(int)eModels.eMassBalance]; auxiliary = (Auxiliary)models[(int)eModels.eAuxiliary]; propulsion = (Propulsion)models[(int)eModels.ePropulsion]; aerodynamics = (Aerodynamics)models[(int)eModels.eAerodynamics]; groundReactions = (GroundReactions)models[(int)eModels.eGroundReactions]; //PENDING new JSBSIM externalReactions = (ExternalReactions)models[(int)eModels.eExternalReactions]; //PENDING new JSBSIM buoyantForces = (BuoyantForces)models[(int)eModels.eBuoyantForces]; aircraft = (Aircraft)models[(int)eModels.eAircraft]; accelerations = (Accelerations)models[(int)eModels.eAccelerations]; //PENDING new JSBSIM output = (Output)models[(int)eModels.eOutput]; // Initialize planet (environment) constants LoadPlanetConstants(); // Initialize models for (int i = 0; i < models.Length; i++) { // The Input/Output models must not be initialized prior to IC loading if (i == (int)eModels.eInput || i == (int)eModels.eOutput) { continue; } //PENDING new JSBSIM LoadInputs(i); if (models[i] != null) { models[i].InitModel(); } } ic = new InitialCondition(this); ic.Bind(instance); modelLoaded = false; return(result); //---------------------- old code pending #if DELETEME bool result = true; massBalance = new MassBalance(this); //output = new Output(this); input = new Input(this); //TODO groundCallback = new DefaultGroundCallback(); state = new State(this); // This must be done here, as the State // class needs valid pointers to the above model classes // Initialize models so they can communicate with each other if (!atmosphere.InitModel()) { if (log.IsErrorEnabled) { log.Error("Atmosphere model init failed"); } error += 1; } if (!FCS.InitModel()) { if (log.IsErrorEnabled) { log.Error("FCS model init failed"); } error += 2; } if (!propulsion.InitModel()) { if (log.IsErrorEnabled) { log.Error("Propulsion model init failed"); } error += 4; } if (!massBalance.InitModel()) { if (log.IsErrorEnabled) { log.Error("MassBalance model init failed"); } error += 8; } if (!aerodynamics.InitModel()) { if (log.IsErrorEnabled) { log.Error("Aerodynamics model init failed"); } error += 16; } if (!inertial.InitModel()) { if (log.IsErrorEnabled) { log.Error("Inertial model init failed"); } error += 32; } if (!groundReactions.InitModel()) { if (log.IsErrorEnabled) { log.Error("Ground Reactions model init failed"); } error += 64; } if (!aircraft.InitModel()) { if (log.IsErrorEnabled) { log.Error("Aircraft model init failed"); } error += 128; } if (!propagate.InitModel()) { if (log.IsErrorEnabled) { log.Error("Propagate model init failed"); } error += 256; } if (!auxiliary.InitModel()) { if (log.IsErrorEnabled) { log.Error("Auxiliary model init failed"); } error += 512; } if (!input.InitModel()) { if (log.IsErrorEnabled) { log.Error("Intput model init failed"); } error += 1024; } if (error > 0) { result = false; } ic = new InitialCondition(this); // Schedule a model. The second arg (the integer) is the pass number. For // instance, the atmosphere model gets executed every fifth pass it is called // by the executive. Everything else here gets executed each pass. // IC and Trim objects are NOT scheduled. Schedule(input, 1); Schedule(atmosphere, 1); Schedule(FCS, 1); Schedule(propulsion, 1); Schedule(massBalance, 1); Schedule(aerodynamics, 1); Schedule(inertial, 1); Schedule(groundReactions, 1); Schedule(aircraft, 1); Schedule(propagate, 1); Schedule(auxiliary, 1); //Schedule(output, 1); modelLoaded = false; return(result); #endif }
private static void Main() //****************************************************************************80 // // Purpose: // // FD1D_ADVECTION_LAX_WENDROFF: advection equation using Lax-Wendroff method. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 12 March 2013 // // Author: // // John Burkardt // { const string command_filename = "advection_commands.txt"; List <string> command_unit = new(); const string data_filename = "advection_data.txt"; List <string> data_unit = new(); int i; int j; Console.WriteLine(""); Console.WriteLine("FD1D_ADVECTION_LAX_WENDROFF:"); Console.WriteLine(""); Console.WriteLine(" Solve the constant-velocity advection equation in 1D,"); Console.WriteLine(" du/dt = - c du/dx"); Console.WriteLine(" over the interval:"); Console.WriteLine(" 0.0 <= x <= 1.0"); Console.WriteLine(" with periodic boundary conditions, and"); Console.WriteLine(" with a given initial condition"); Console.WriteLine(" u(0,x) = (10x-4)^2 (6-10x)^2 for 0.4 <= x <= 0.6"); Console.WriteLine(" = 0 elsewhere."); Console.WriteLine(""); Console.WriteLine(" We modify the FTCS method using the Lax-Wendroff method:"); const int nx = 101; const double dx = 1.0 / (nx - 1); const double a = 0.0; const double b = 1.0; double[] x = typeMethods.r8vec_linspace_new(nx, a, b); const int nt = 1000; const double dt = 1.0 / nt; const double c = 1.0; const double c1 = 0.5 * c * dt / dx; double c2 = 0.5 * Math.Pow(c * dt / dx, 2); double[] u = InitialCondition.initial_condition(nx, x); // // Open data file, and write solutions as they are computed. // double t = 0.0; data_unit.Add(" " + x[0] + " " + t + " " + u[0] + ""); for (j = 0; j < nx; j++) { data_unit.Add(" " + x[j] + " " + t + " " + u[j] + ""); } data_unit.Add(""); int nt_step = 100; Console.WriteLine(""); Console.WriteLine(" Number of nodes NX = " + nx + ""); Console.WriteLine(" Number of time steps NT = " + nt + ""); Console.WriteLine(" Constant velocity C = " + c + ""); Console.WriteLine(" CFL condition: dt (" + dt + ") <= dx / c (" + dx / c + ")"); double[] unew = new double[nx]; for (i = 0; i < nt; i++) { for (j = 0; j < nx; j++) { int jm1 = typeMethods.i4_wrap(j - 1, 0, nx - 1); int jp1 = typeMethods.i4_wrap(j + 1, 0, nx - 1); unew[j] = u[j] - c1 * (u[jp1] - u[jm1]) + c2 * (u[jp1] - 2.0 * u[j] + u[jm1]); } for (j = 0; j < nx; j++) { u[j] = unew[j]; } if (i != nt_step - 1) { continue; } t = i * dt; for (j = 0; j < nx; j++) { data_unit.Add(" " + x[j] + " " + t + " " + u[j] + ""); } data_unit.Add(""); nt_step += 100; } // // Close the data file once the computation is done. // File.WriteAllLines(data_filename, data_unit); Console.WriteLine(""); Console.WriteLine(" Plot data written to the file \"" + data_filename + "\""); // // Write gnuplot command file. // command_unit.Add("set term png"); command_unit.Add("set output 'advection_lax_wendroff.png'"); command_unit.Add("set grid"); command_unit.Add("set style data lines"); command_unit.Add("unset key"); command_unit.Add("set xlabel '<---X--->'"); command_unit.Add("set ylabel '<---Time--->'"); command_unit.Add("splot '" + data_filename + "' using 1:2:3 with lines"); command_unit.Add("quit"); File.WriteAllLines(command_filename, command_unit); Console.WriteLine(" Gnuplot command data written to the file \"" + command_filename + "\""); Console.WriteLine(""); Console.WriteLine("FD1D_ADVECTION_LAX_WENDROFF:"); Console.WriteLine(" Normal end of execution."); Console.WriteLine(""); }