[Earth-EML4 Transfer] Propagation stop at reaching lagrange?

Control flow commands, Target, Vary, Minimize, NonlinearConstraint, etc.

[Earth-EML4 Transfer] Propagation stop at reaching lagrange?

Postby hornig » Wed Mar 06, 2013 10:45 am

Hi there,

I post my question to this new thread, because it's rather a specific command question than a mission question.
What I try to do is to set up a transfer to Earth-Moon libration EML-4 point.
I managed to include an even script where the current distance to the EML-4 is calculated and used for "achieve".
I currently use apoapsis for the propagation stop, but that's not a fine way because it is sensitive to the maneuver time and the apogee position could be very far of. It mostly happens that GMAT takes ages to calculate it and sometimes freezes.

So my question is what other propagator stop condition should I use? I tried to directly use the variable of the distance to EML-4, but that throws error messages.
What I want in this step is, that the propagation stops when the EML-4 is reached in any attitude.

What do you advise here?

Thanks in advance,

Andreas


Here's the script

Code: Select all
%General Mission Analysis Tool(GMAT) Script
%Created: 2013-03-05 10:33:29


%----------------------------------------
%---------- Calculated Points
%----------------------------------------

Create LibrationPoint Libration1;
GMAT Libration1.Primary = Earth;
GMAT Libration1.Secondary = Luna;
GMAT Libration1.Point = L4;

%----------------------------------------
%---------- Spacecraft
%----------------------------------------

Create Spacecraft DefaultSC;
GMAT DefaultSC.DateFormat = TAIModJulian;
GMAT DefaultSC.Epoch = '21545';
GMAT DefaultSC.CoordinateSystem = EarthMJ2000Eq;
GMAT DefaultSC.DisplayStateType = Keplerian;
GMAT DefaultSC.SMA = 6841.83198639967;
GMAT DefaultSC.ECC = 0.03773375524472419;
GMAT DefaultSC.INC = 28;
GMAT DefaultSC.RAAN = 0;
GMAT DefaultSC.AOP = 180;
GMAT DefaultSC.TA = 180;
GMAT DefaultSC.DryMass = 850;
GMAT DefaultSC.Cd = 2.2;
GMAT DefaultSC.Cr = 1.8;
GMAT DefaultSC.DragArea = 15;
GMAT DefaultSC.SRPArea = 1;
GMAT DefaultSC.NAIFId = -123456789;
GMAT DefaultSC.NAIFIdReferenceFrame = -123456789;
GMAT DefaultSC.Id = 'SatId';
GMAT DefaultSC.Attitude = CoordinateSystemFixed;
GMAT DefaultSC.ModelFile = '../data/vehicle/models/aura.3ds';
GMAT DefaultSC.ModelOffsetX = 0;
GMAT DefaultSC.ModelOffsetY = 0;
GMAT DefaultSC.ModelOffsetZ = 0;
GMAT DefaultSC.ModelRotationX = 0;
GMAT DefaultSC.ModelRotationY = 0;
GMAT DefaultSC.ModelRotationZ = 0;
GMAT DefaultSC.ModelScale = 3;
GMAT DefaultSC.AttitudeDisplayStateType = 'Quaternion';
GMAT DefaultSC.AttitudeRateDisplayStateType = 'AngularVelocity';
GMAT DefaultSC.AttitudeCoordinateSystem = 'EarthMJ2000Eq';
GMAT DefaultSC.Q1 = 0;
GMAT DefaultSC.Q2 = 0;
GMAT DefaultSC.Q3 = 0;
GMAT DefaultSC.Q4 = 1;
GMAT DefaultSC.EulerAngleSequence = '321';
GMAT DefaultSC.AngularVelocityX = 0;
GMAT DefaultSC.AngularVelocityY = 0;
GMAT DefaultSC.AngularVelocityZ = 0;







%----------------------------------------
%---------- ForceModels
%----------------------------------------

Create ForceModel DefaultProp_ForceModel;
GMAT DefaultProp_ForceModel.CentralBody = Earth;
GMAT DefaultProp_ForceModel.PrimaryBodies = {Earth};
GMAT DefaultProp_ForceModel.Drag = None;
GMAT DefaultProp_ForceModel.SRP = Off;
GMAT DefaultProp_ForceModel.RelativisticCorrection = Off;
GMAT DefaultProp_ForceModel.ErrorControl = RSSStep;
GMAT DefaultProp_ForceModel.GravityField.Earth.Degree = 4;
GMAT DefaultProp_ForceModel.GravityField.Earth.Order = 4;
GMAT DefaultProp_ForceModel.GravityField.Earth.PotentialFile = 'JGM2.cof';
GMAT DefaultProp_ForceModel.GravityField.Earth.EarthTideModel = 'None';

%----------------------------------------
%---------- Propagators
%----------------------------------------

Create Propagator DefaultProp;
GMAT DefaultProp.FM = DefaultProp_ForceModel;
GMAT DefaultProp.Type = RungeKutta89;
GMAT DefaultProp.InitialStepSize = 60;
GMAT DefaultProp.Accuracy = 9.999999999999999e-012;
GMAT DefaultProp.MinStep = 0.001;
GMAT DefaultProp.MaxStep = 2700;
GMAT DefaultProp.MaxStepAttempts = 50;
GMAT DefaultProp.StopIfAccuracyIsViolated = true;

%----------------------------------------
%---------- Burns
%----------------------------------------

Create ImpulsiveBurn DefaultIB;
GMAT DefaultIB.CoordinateSystem = Local;
GMAT DefaultIB.Origin = Earth;
GMAT DefaultIB.Axes = VNB;
GMAT DefaultIB.Element1 = 0;
GMAT DefaultIB.Element2 = 0;
GMAT DefaultIB.Element3 = 0;
GMAT DefaultIB.DecrementMass = false;
GMAT DefaultIB.Isp = 300;
GMAT DefaultIB.GravitationalAccel = 9.810000000000001;

%----------------------------------------
%---------- Arrays, Variables, Strings
%----------------------------------------
Create Variable EML4_distance EML4_x EML4_y EML4_z;
GMAT EML4_distance = 0;
GMAT EML4_x = 0;
GMAT EML4_y = 0;
GMAT EML4_z = 0;






%----------------------------------------
%---------- Coordinate Systems
%----------------------------------------

Create CoordinateSystem EML4_rev;
GMAT EML4_rev.Origin = Libration1;
GMAT EML4_rev.Axes = ObjectReferenced;
GMAT EML4_rev.XAxis = R;
GMAT EML4_rev.ZAxis = N;
GMAT EML4_rev.Primary = Earth;
GMAT EML4_rev.Secondary = Libration1;

%----------------------------------------
%---------- Solvers
%----------------------------------------

Create DifferentialCorrector DefaultDC;
GMAT DefaultDC.ShowProgress = true;
GMAT DefaultDC.ReportStyle = Normal;
GMAT DefaultDC.ReportFile = 'DifferentialCorrectorDefaultDC.data';
GMAT DefaultDC.MaximumIterations = 25;
GMAT DefaultDC.DerivativeMethod = ForwardDifference;

%----------------------------------------
%---------- Subscribers
%----------------------------------------

Create OrbitView DefaultOrbitView;
GMAT DefaultOrbitView.SolverIterations = Current;
GMAT DefaultOrbitView.UpperLeft = [ 0.4450261780104712 0 ];
GMAT DefaultOrbitView.Size = [ 0.5052356020942408 0.4572490706319702 ];
GMAT DefaultOrbitView.RelativeZOrder = 448;
GMAT DefaultOrbitView.Add = {DefaultSC, Earth};
GMAT DefaultOrbitView.CoordinateSystem = EarthMJ2000Eq;
GMAT DefaultOrbitView.DrawObject = [ true true ];
GMAT DefaultOrbitView.OrbitColor = [ 255 32768 ];
GMAT DefaultOrbitView.TargetColor = [ 8421440 0 ];
GMAT DefaultOrbitView.DataCollectFrequency = 1;
GMAT DefaultOrbitView.UpdatePlotFrequency = 50;
GMAT DefaultOrbitView.NumPointsToRedraw = 0;
GMAT DefaultOrbitView.ShowPlot = true;
GMAT DefaultOrbitView.ViewPointReference = Earth;
GMAT DefaultOrbitView.ViewPointVector = [ 30000 0 0 ];
GMAT DefaultOrbitView.ViewDirection = Earth;
GMAT DefaultOrbitView.ViewScaleFactor = 1;
GMAT DefaultOrbitView.ViewUpCoordinateSystem = EarthMJ2000Eq;
GMAT DefaultOrbitView.ViewUpAxis = Z;
GMAT DefaultOrbitView.CelestialPlane = Off;
GMAT DefaultOrbitView.XYPlane = On;
GMAT DefaultOrbitView.WireFrame = Off;
GMAT DefaultOrbitView.Axes = On;
GMAT DefaultOrbitView.Grid = Off;
GMAT DefaultOrbitView.SunLine = Off;
GMAT DefaultOrbitView.UseInitialView = On;
GMAT DefaultOrbitView.StarCount = 7000;
GMAT DefaultOrbitView.EnableStars = On;
GMAT DefaultOrbitView.EnableConstellations = On;

Create GroundTrackPlot DefaultGroundTrackPlot;
GMAT DefaultGroundTrackPlot.SolverIterations = Current;
GMAT DefaultGroundTrackPlot.UpperLeft = [ 0.004363001745200698 0.4591078066914498 ];
GMAT DefaultGroundTrackPlot.Size = [ 0.5052356020942408 0.4572490706319702 ];
GMAT DefaultGroundTrackPlot.RelativeZOrder = 215;
GMAT DefaultGroundTrackPlot.Add = {DefaultSC, Earth};
GMAT DefaultGroundTrackPlot.DataCollectFrequency = 1;
GMAT DefaultGroundTrackPlot.UpdatePlotFrequency = 50;
GMAT DefaultGroundTrackPlot.NumPointsToRedraw = 0;
GMAT DefaultGroundTrackPlot.ShowPlot = true;
GMAT DefaultGroundTrackPlot.CentralBody = Earth;
GMAT DefaultGroundTrackPlot.TextureMap = '../data/graphics/texture/ModifiedBlueMarble.jpg';

Create OrbitView OrbitView1;
GMAT OrbitView1.SolverIterations = Current;
GMAT OrbitView1.UpperLeft = [ 0.3970331588132635 0.3903345724907063 ];
GMAT OrbitView1.Size = [ 0.5052356020942408 0.4572490706319702 ];
GMAT OrbitView1.RelativeZOrder = 479;
GMAT OrbitView1.Add = {DefaultSC, Earth, Luna};
GMAT OrbitView1.CoordinateSystem = EML4_rev;
GMAT OrbitView1.DrawObject = [ true true true ];
GMAT OrbitView1.OrbitColor = [ 255 32768 1743054 ];
GMAT OrbitView1.TargetColor = [ 8421440 0 4227327 ];
GMAT OrbitView1.DataCollectFrequency = 1;
GMAT OrbitView1.UpdatePlotFrequency = 50;
GMAT OrbitView1.NumPointsToRedraw = 0;
GMAT OrbitView1.ShowPlot = true;
GMAT OrbitView1.ViewPointReference = Libration1;
GMAT OrbitView1.ViewPointVector = [ 0 0 1 ];
GMAT OrbitView1.ViewDirection = Libration1;
GMAT OrbitView1.ViewScaleFactor = 1000000;
GMAT OrbitView1.ViewUpCoordinateSystem = EML4_rev;
GMAT OrbitView1.ViewUpAxis = Z;
GMAT OrbitView1.CelestialPlane = Off;
GMAT OrbitView1.XYPlane = On;
GMAT OrbitView1.WireFrame = Off;
GMAT OrbitView1.Axes = On;
GMAT OrbitView1.Grid = Off;
GMAT OrbitView1.SunLine = Off;
GMAT OrbitView1.UseInitialView = On;
GMAT OrbitView1.StarCount = 7000;
GMAT OrbitView1.EnableStars = On;
GMAT OrbitView1.EnableConstellations = On;

Create ReportFile DefaultReportFile;
GMAT DefaultReportFile.SolverIterations = Current;
GMAT DefaultReportFile.UpperLeft = [ 0 0 ];
GMAT DefaultReportFile.Size = [ 0 0 ];
GMAT DefaultReportFile.RelativeZOrder = 0;
GMAT DefaultReportFile.Filename = 'DefaultReportFile.txt';
GMAT DefaultReportFile.Precision = 16;
GMAT DefaultReportFile.WriteHeaders = On;
GMAT DefaultReportFile.LeftJustify = On;
GMAT DefaultReportFile.ZeroFill = Off;
GMAT DefaultReportFile.ColumnWidth = 20;
GMAT DefaultReportFile.WriteReport = true;

Create XYPlot XYPlot1;
GMAT XYPlot1.SolverIterations = Current;
GMAT XYPlot1.UpperLeft = [ -0.03490401396160558 0.02788104089219331 ];
GMAT XYPlot1.Size = [ 0.5008726003490401 0.4516728624535316 ];
GMAT XYPlot1.RelativeZOrder = 334;
GMAT XYPlot1.XVariable = DefaultSC.ElapsedSecs;
GMAT XYPlot1.YVariables = {EML4_x, EML4_y, EML4_z};
GMAT XYPlot1.ShowGrid = true;
GMAT XYPlot1.ShowPlot = true;

Create XYPlot XYPlot2;
GMAT XYPlot2.SolverIterations = Current;
GMAT XYPlot2.UpperLeft = [ 0.004363001745200698 0.4907063197026023 ];
GMAT XYPlot2.Size = [ 0.5017452006980803 0.4535315985130112 ];
GMAT XYPlot2.RelativeZOrder = 493;
GMAT XYPlot2.XVariable = DefaultSC.ElapsedSecs;
GMAT XYPlot2.YVariables = {EML4_distance};
GMAT XYPlot2.ShowGrid = true;
GMAT XYPlot2.ShowPlot = true;


%----------------------------------------
%---------- Mission Sequence
%----------------------------------------

BeginMissionSequence;
Propagate DefaultProp(DefaultSC) {DefaultSC.ElapsedSecs = 14000.0};
Target DefaultDC {SolveMode = Solve, ExitMode = DiscardAndContinue};
   Vary DefaultDC(DefaultIB.Element2 = 0.5, {Perturbation = 0.0001, Lower = 0.0, Upper = 3.14159, MaxStep = 0.2});
   Vary DefaultDC(DefaultIB.Element1 = 0.5, {Perturbation = 0.0001, Lower = 0.0, Upper = 3.14159, MaxStep = 0.2});
   Vary DefaultDC(DefaultIB.Element3 = 0.5, {Perturbation = 0.0001, Lower = 0.0, Upper = 3.14159, MaxStep = 0.2});
   Maneuver DefaultIB(DefaultSC);
   Propagate DefaultProp(DefaultSC) {DefaultSC.Earth.Apoapsis};
   BeginScript
      GMAT EML4_x = DefaultSC.EML4_rev.X;
      GMAT EML4_y = DefaultSC.EML4_rev.Y;
      GMAT EML4_z = DefaultSC.EML4_rev.Z;
     
      GMAT EML4_distance = (EML4_x^2+EML4_y^2+EML4_z^2)^0.5;
   EndScript;
   Achieve DefaultDC(EML4_distance = 0, {Tolerance = 0.1});
EndTarget;  % For targeter DefaultDC
hornig
 
Posts: 28
Joined: Fri Nov 30, 2012 3:16 pm

Re: [Earth-EML4 Transfer] Propagation stop at reaching lagra

Postby hornig » Wed Mar 06, 2013 5:00 pm

Hi there,

I just found the "while loop" and how to tell the propagator to work without parameter. at least this works for me and I checked several end statements with test statements for this unrelated mission.
it checks for
a certain maximum altitude
if the distance RMAG is bigger then the previous one
and a maximum allowed prop time to have an emergency stop for this loop

so, would you also do this in this way? :)

Code: Select all
%General Mission Analysis Tool(GMAT) Script
%Created: 2013-03-06 05:56:30


%----------------------------------------
%---------- Spacecraft
%----------------------------------------

Create Spacecraft DefaultSC;
GMAT DefaultSC.DateFormat = TAIModJulian;
GMAT DefaultSC.Epoch = '21545';
GMAT DefaultSC.CoordinateSystem = EarthMJ2000Eq;
GMAT DefaultSC.DisplayStateType = Cartesian;
GMAT DefaultSC.X = 7100;
GMAT DefaultSC.Y = 0;
GMAT DefaultSC.Z = 1300;
GMAT DefaultSC.VX = 0;
GMAT DefaultSC.VY = 7.35;
GMAT DefaultSC.VZ = 1;
GMAT DefaultSC.DryMass = 850;
GMAT DefaultSC.Cd = 2.2;
GMAT DefaultSC.Cr = 1.8;
GMAT DefaultSC.DragArea = 15;
GMAT DefaultSC.SRPArea = 1;
GMAT DefaultSC.NAIFId = -123456789;
GMAT DefaultSC.NAIFIdReferenceFrame = -123456789;
GMAT DefaultSC.Id = 'SatId';
GMAT DefaultSC.Attitude = CoordinateSystemFixed;
GMAT DefaultSC.ModelFile = '../data/vehicle/models/aura.3ds';
GMAT DefaultSC.ModelOffsetX = 0;
GMAT DefaultSC.ModelOffsetY = 0;
GMAT DefaultSC.ModelOffsetZ = 0;
GMAT DefaultSC.ModelRotationX = 0;
GMAT DefaultSC.ModelRotationY = 0;
GMAT DefaultSC.ModelRotationZ = 0;
GMAT DefaultSC.ModelScale = 3;
GMAT DefaultSC.AttitudeDisplayStateType = 'Quaternion';
GMAT DefaultSC.AttitudeRateDisplayStateType = 'AngularVelocity';
GMAT DefaultSC.AttitudeCoordinateSystem = 'EarthMJ2000Eq';
GMAT DefaultSC.Q1 = 0;
GMAT DefaultSC.Q2 = 0;
GMAT DefaultSC.Q3 = 0;
GMAT DefaultSC.Q4 = 1;
GMAT DefaultSC.EulerAngleSequence = '321';
GMAT DefaultSC.AngularVelocityX = 0;
GMAT DefaultSC.AngularVelocityY = 0;
GMAT DefaultSC.AngularVelocityZ = 0;

Create ForceModel DefaultProp_ForceModel;
GMAT DefaultProp_ForceModel.CentralBody = Earth;
GMAT DefaultProp_ForceModel.PrimaryBodies = {Earth};
GMAT DefaultProp_ForceModel.Drag = None;
GMAT DefaultProp_ForceModel.SRP = Off;
GMAT DefaultProp_ForceModel.RelativisticCorrection = Off;
GMAT DefaultProp_ForceModel.ErrorControl = RSSStep;
GMAT DefaultProp_ForceModel.GravityField.Earth.Degree = 4;
GMAT DefaultProp_ForceModel.GravityField.Earth.Order = 4;
GMAT DefaultProp_ForceModel.GravityField.Earth.PotentialFile = 'JGM2.cof';
GMAT DefaultProp_ForceModel.GravityField.Earth.EarthTideModel = 'None';

%----------------------------------------
%---------- Propagators
%----------------------------------------

Create Propagator DefaultProp;
GMAT DefaultProp.FM = DefaultProp_ForceModel;
GMAT DefaultProp.Type = RungeKutta89;
GMAT DefaultProp.InitialStepSize = 60;
GMAT DefaultProp.Accuracy = 9.999999999999999e-012;
GMAT DefaultProp.MinStep = 0.001;
GMAT DefaultProp.MaxStep = 2700;
GMAT DefaultProp.MaxStepAttempts = 50;
GMAT DefaultProp.StopIfAccuracyIsViolated = true;

%----------------------------------------
%---------- Burns
%----------------------------------------

Create ImpulsiveBurn DefaultIB;
GMAT DefaultIB.CoordinateSystem = Local;
GMAT DefaultIB.Origin = Earth;
GMAT DefaultIB.Axes = VNB;
GMAT DefaultIB.Element1 = 2.8;
GMAT DefaultIB.Element2 = 0;
GMAT DefaultIB.Element3 = 0;
GMAT DefaultIB.DecrementMass = false;
GMAT DefaultIB.Isp = 300;
GMAT DefaultIB.GravitationalAccel = 9.810000000000001;

%----------------------------------------
%---------- Arrays, Variables, Strings
%----------------------------------------
Create Variable sc_distance sc_distance_b4;
GMAT sc_distance = 0;
GMAT sc_distance_b4 = 0;


%----------------------------------------
%---------- Subscribers
%----------------------------------------

Create OrbitView DefaultOrbitView;
GMAT DefaultOrbitView.SolverIterations = Current;
GMAT DefaultOrbitView.UpperLeft = [ 0.004591368227731864 0 ];
GMAT DefaultOrbitView.Size = [ 0.5004591368227732 0.4516728624535316 ];
GMAT DefaultOrbitView.RelativeZOrder = 876;
GMAT DefaultOrbitView.Add = {DefaultSC, Earth};
GMAT DefaultOrbitView.CoordinateSystem = EarthMJ2000Eq;
GMAT DefaultOrbitView.DrawObject = [ true true ];
GMAT DefaultOrbitView.OrbitColor = [ 255 32768 ];
GMAT DefaultOrbitView.TargetColor = [ 8421440 0 ];
GMAT DefaultOrbitView.DataCollectFrequency = 1;
GMAT DefaultOrbitView.UpdatePlotFrequency = 50;
GMAT DefaultOrbitView.NumPointsToRedraw = 0;
GMAT DefaultOrbitView.ShowPlot = true;
GMAT DefaultOrbitView.ViewPointReference = Earth;
GMAT DefaultOrbitView.ViewPointVector = [ 30000 0 0 ];
GMAT DefaultOrbitView.ViewDirection = Earth;
GMAT DefaultOrbitView.ViewScaleFactor = 1;
GMAT DefaultOrbitView.ViewUpCoordinateSystem = EarthMJ2000Eq;
GMAT DefaultOrbitView.ViewUpAxis = Z;
GMAT DefaultOrbitView.CelestialPlane = Off;
GMAT DefaultOrbitView.XYPlane = On;
GMAT DefaultOrbitView.WireFrame = Off;
GMAT DefaultOrbitView.Axes = On;
GMAT DefaultOrbitView.Grid = Off;
GMAT DefaultOrbitView.SunLine = Off;
GMAT DefaultOrbitView.UseInitialView = On;
GMAT DefaultOrbitView.StarCount = 7000;
GMAT DefaultOrbitView.EnableStars = On;
GMAT DefaultOrbitView.EnableConstellations = On;

Create GroundTrackPlot DefaultGroundTrackPlot;
GMAT DefaultGroundTrackPlot.SolverIterations = Current;
GMAT DefaultGroundTrackPlot.UpperLeft = [ 0.004591368227731864 0.4591078066914498 ];
GMAT DefaultGroundTrackPlot.Size = [ 0.5004591368227732 0.4516728624535316 ];
GMAT DefaultGroundTrackPlot.RelativeZOrder = 716;
GMAT DefaultGroundTrackPlot.Add = {DefaultSC, Earth};
GMAT DefaultGroundTrackPlot.DataCollectFrequency = 1;
GMAT DefaultGroundTrackPlot.UpdatePlotFrequency = 50;
GMAT DefaultGroundTrackPlot.NumPointsToRedraw = 0;
GMAT DefaultGroundTrackPlot.ShowPlot = true;
GMAT DefaultGroundTrackPlot.CentralBody = Earth;
GMAT DefaultGroundTrackPlot.TextureMap = '../data/graphics/texture/ModifiedBlueMarble.jpg';


%----------------------------------------
%---------- Mission Sequence
%----------------------------------------

BeginMissionSequence;
Propagate DefaultProp(DefaultSC) {DefaultSC.ElapsedSecs = 12000.0};
Maneuver DefaultIB(DefaultSC);
While sc_distance < 800000 & DefaultSC.ElapsedSecs < 1000000 & sc_distance >= sc_distance_b4
   BeginScript
      GMAT sc_distance_b4 = sc_distance;
   EndScript;
   Propagate DefaultProp(DefaultSC);
   BeginScript
      GMAT sc_distance = DefaultSC.Earth.RMAG;
   EndScript;
EndWhile;
hornig
 
Posts: 28
Joined: Fri Nov 30, 2012 3:16 pm


Return to GMAT Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron