Propagate until eclipse

Spacecraft, Thruster, Tank, Propagator, CoordinateSystem, etc.

Propagate until eclipse

Postby GillesMariotti » Wed Feb 03, 2016 8:28 am

Hi all,

I have recently begun working with GMAT, and I just registered to the board to ask for your help.

I would like to set up a mission sequence during which a low-thrust spacraft fires the thruster only when it is eclipsed. I tought that it would be possible to set the propagator to stop at the beginning of the eclipse, but I cannot find the related parameter.

Is it possible at all?


So far I have tried these workarounds:

- propagate until the available thrust from the solar power system reaches zero. Then empty the shadow bodies of the solar power system (in order to have again available thrust) and start a finite burn. This approach fails since the propagator of the first step of the list crashes returning an error: "unable to interpolate stop epoch"

-create a variable that switches between 0 and 1 based on the eclipse formulation from Navipedia. Then in a while loop, propagate 1s and continously update the custom variable with a gmat function until the variable switches to 1. Then start the finite burn. This sequence works but is incredibly slow.

Thank you in advance for your help!
GillesMariotti
 
Posts: 6
Joined: Tue Feb 02, 2016 5:09 pm

Re: Propagate until eclipse

Postby jjkparker » Sat Feb 13, 2016 7:51 pm

A good question - you probably noticed in R2015a we have support for eclipse reporting, but not interaction with eclipse data inside the script itself. That's future development that we look forward to doing, but it's not on the radar at this moment.

For method #1, can you attach the script you used? We might want to look into the propagation failure here.

For method #2, have you tried using a Python function instead of a GMAT function (or putting the calculation inline)? That might give you a speed boost, at least. Do you really need 1s accuracy as well?
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: Propagate until eclipse

Postby GillesMariotti » Mon Feb 15, 2016 8:44 am

Dear Joel,

thank you very much for your reply.

For method #1, you will find my barebone script below.

For method #2: I have tried both MATLAB and GMAT functions, and noticed a significant speed advantage for the GMAT function implementation (the same simulation run with the GMAT function needed roughly the 60% of the time taken by the MATLAB function script). I have not tried Python nor inline yet (I guess by inline you mean what in the GUI is called "equation", right?). I will try and check if they are any faster.
In the end probably I don't really need 1s accuracy, I think I can get away with a 60s step, that makes the simulation running time somewhat feasible (1 year simulation = 4 hours).

I'll ask you another question: is there any possibility to tell the "propagate" command to vary a user variable during the propagation, by adding a custom function or the partial derivatives of the variable?


Thank you again,
Gilles

Code: Select all
%General Mission Analysis Tool(GMAT) Script
%Created: 2016-01-18 13:37:05


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

Create Spacecraft DefaultSC;
GMAT DefaultSC.DateFormat = UTCGregorian;
GMAT DefaultSC.Epoch = '01 Jul 2019 00:00:00.000';
GMAT DefaultSC.CoordinateSystem = EarthMJ2000Eq;
GMAT DefaultSC.DisplayStateType = Keplerian;
GMAT DefaultSC.SMA = 6977.999999999998;
GMAT DefaultSC.ECC = 2.74007051675202e-016;
GMAT DefaultSC.INC = 97.78740000000001;
GMAT DefaultSC.RAAN = 76.737866;
GMAT DefaultSC.AOP = 0;
GMAT DefaultSC.TA = 90;
GMAT DefaultSC.DryMass = 57;
GMAT DefaultSC.Cd = 2.2;
GMAT DefaultSC.Cr = 1.8;
GMAT DefaultSC.DragArea = 0.2601;
GMAT DefaultSC.SRPArea = 1;
GMAT DefaultSC.Tanks = {ElectricTank1};
GMAT DefaultSC.Thrusters = {ElectricThruster1};
GMAT DefaultSC.PowerSystem = SolarPowerSystem1;
GMAT DefaultSC.NAIFId = -10004001;
GMAT DefaultSC.NAIFIdReferenceFrame = -9004001;
GMAT DefaultSC.OrbitColor = Red;
GMAT DefaultSC.TargetColor = Teal;
GMAT DefaultSC.Id = 'SatId';
GMAT DefaultSC.Attitude = CoordinateSystemFixed;
GMAT DefaultSC.SPADSRPScaleFactor = 1;
GMAT DefaultSC.ModelFile = '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 = 1;
GMAT DefaultSC.AttitudeDisplayStateType = 'Quaternion';
GMAT DefaultSC.AttitudeRateDisplayStateType = 'AngularVelocity';
GMAT DefaultSC.AttitudeCoordinateSystem = EarthMJ2000Eq;
GMAT DefaultSC.EulerAngleSequence = '313';

%----------------------------------------
%---------- Hardware Components
%----------------------------------------

Create SolarPowerSystem SolarPowerSystem1;
GMAT SolarPowerSystem1.EpochFormat = 'UTCGregorian';
GMAT SolarPowerSystem1.InitialEpoch = ''01 Jul 2019 00:00:00.000'';
GMAT SolarPowerSystem1.InitialMaxPower = 1;
GMAT SolarPowerSystem1.AnnualDecayRate = 5;
GMAT SolarPowerSystem1.Margin = 5;
GMAT SolarPowerSystem1.BusCoeff1 = 0.05;
GMAT SolarPowerSystem1.BusCoeff2 = 0;
GMAT SolarPowerSystem1.BusCoeff3 = 0;
GMAT SolarPowerSystem1.ShadowModel = 'DualCone';
GMAT SolarPowerSystem1.ShadowBodies = {'Earth'};
GMAT SolarPowerSystem1.SolarCoeff1 = 1;
GMAT SolarPowerSystem1.SolarCoeff2 = 0;
GMAT SolarPowerSystem1.SolarCoeff3 = 0;
GMAT SolarPowerSystem1.SolarCoeff4 = 0;
GMAT SolarPowerSystem1.SolarCoeff5 = 0;

Create ElectricThruster ElectricThruster1;
GMAT ElectricThruster1.CoordinateSystem = Local;
GMAT ElectricThruster1.Origin = Earth;
GMAT ElectricThruster1.Axes = VNB;
GMAT ElectricThruster1.ThrustDirection1 = 1;
GMAT ElectricThruster1.ThrustDirection2 = 0;
GMAT ElectricThruster1.ThrustDirection3 = 0;
GMAT ElectricThruster1.DutyCycle = 1;
GMAT ElectricThruster1.ThrustScaleFactor = 1;
GMAT ElectricThruster1.DecrementMass = true;
GMAT ElectricThruster1.Tank = {ElectricTank1};
GMAT ElectricThruster1.GravitationalAccel = 9.810000000000001;
GMAT ElectricThruster1.ThrustModel = ConstantThrustAndIsp;
GMAT ElectricThruster1.MaximumUsablePower = 0.255;
GMAT ElectricThruster1.MinimumUsablePower = 0.14;
GMAT ElectricThruster1.ThrustCoeff1 = -5.19082;
GMAT ElectricThruster1.ThrustCoeff2 = 2.96519;
GMAT ElectricThruster1.ThrustCoeff3 = -14.4789;
GMAT ElectricThruster1.ThrustCoeff4 = 54.05382;
GMAT ElectricThruster1.ThrustCoeff5 = -0.00100092;
GMAT ElectricThruster1.MassFlowCoeff1 = -0.004776;
GMAT ElectricThruster1.MassFlowCoeff2 = 0.05717;
GMAT ElectricThruster1.MassFlowCoeff3 = -0.09956;
GMAT ElectricThruster1.MassFlowCoeff4 = 0.03211;
GMAT ElectricThruster1.MassFlowCoeff5 = 2.13781;
GMAT ElectricThruster1.FixedEfficiency = 0.7;
GMAT ElectricThruster1.Isp = 900;
GMAT ElectricThruster1.ConstantThrust = 0.007;

Create ElectricTank ElectricTank1;
GMAT ElectricTank1.AllowNegativeFuelMass = false;
GMAT ElectricTank1.FuelMass = 5;



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

Create ForceModel DefaultProp_ForceModel;
GMAT DefaultProp_ForceModel.CentralBody = Earth;
GMAT DefaultProp_ForceModel.PrimaryBodies = {Earth};
GMAT DefaultProp_ForceModel.PointMasses = {Luna, Sun};
GMAT DefaultProp_ForceModel.Drag = None;
GMAT DefaultProp_ForceModel.SRP = On;
GMAT DefaultProp_ForceModel.RelativisticCorrection = On;
GMAT DefaultProp_ForceModel.ErrorControl = RSSStep;
GMAT DefaultProp_ForceModel.GravityField.Earth.Degree = 3;
GMAT DefaultProp_ForceModel.GravityField.Earth.Order = 3;
GMAT DefaultProp_ForceModel.GravityField.Earth.PotentialFile = 'JGM2.cof';
GMAT DefaultProp_ForceModel.GravityField.Earth.EarthTideModel = 'None';
GMAT DefaultProp_ForceModel.SRP.Flux = 1367;
GMAT DefaultProp_ForceModel.SRP.SRPModel = Spherical;
GMAT DefaultProp_ForceModel.SRP.Nominal_Sun = 149597870.691;

%----------------------------------------
%---------- 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;

Create FiniteBurn elec_Fburn;
GMAT elec_Fburn.Thrusters = {ElectricThruster1};
GMAT elec_Fburn.ThrottleLogicAlgorithm = 'MaxNumberOfThrusters';

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

Create DifferentialCorrector DC1;
GMAT DC1.ShowProgress = true;
GMAT DC1.ReportStyle = Normal;
GMAT DC1.ReportFile = 'DifferentialCorrectorDC1.data';
GMAT DC1.MaximumIterations = 25;
GMAT DC1.DerivativeMethod = ForwardDifference;
GMAT DC1.Algorithm = NewtonRaphson;

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

Create OrbitView DefaultOrbitView;
GMAT DefaultOrbitView.SolverIterations = Current;
GMAT DefaultOrbitView.UpperLeft = [ 0.006108202443280977 0.005681818181818182 ];
GMAT DefaultOrbitView.Size = [ 0.5104712041884817 0.4507575757575758 ];
GMAT DefaultOrbitView.RelativeZOrder = 64;
GMAT DefaultOrbitView.Maximized = false;
GMAT DefaultOrbitView.Add = {DefaultSC, Earth, Sun};
GMAT DefaultOrbitView.CoordinateSystem = EarthMJ2000Eq;
GMAT DefaultOrbitView.DrawObject = [ true true true ];
GMAT DefaultOrbitView.DataCollectFrequency = 1;
GMAT DefaultOrbitView.UpdatePlotFrequency = 50;
GMAT DefaultOrbitView.NumPointsToRedraw = 0;
GMAT DefaultOrbitView.ShowPlot = true;
GMAT DefaultOrbitView.ShowLabels = 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.EclipticPlane = Off;
GMAT DefaultOrbitView.XYPlane = On;
GMAT DefaultOrbitView.WireFrame = Off;
GMAT DefaultOrbitView.Axes = On;
GMAT DefaultOrbitView.Grid = Off;
GMAT DefaultOrbitView.SunLine = On;
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.001745200698080279 0.4393939393939394 ];
GMAT DefaultGroundTrackPlot.Size = [ 0.5104712041884817 0.4507575757575758 ];
GMAT DefaultGroundTrackPlot.RelativeZOrder = 20;
GMAT DefaultGroundTrackPlot.Maximized = false;
GMAT DefaultGroundTrackPlot.Add = {DefaultSC};
GMAT DefaultGroundTrackPlot.DataCollectFrequency = 1;
GMAT DefaultGroundTrackPlot.UpdatePlotFrequency = 50;
GMAT DefaultGroundTrackPlot.NumPointsToRedraw = 0;
GMAT DefaultGroundTrackPlot.ShowPlot = true;
GMAT DefaultGroundTrackPlot.CentralBody = Earth;
GMAT DefaultGroundTrackPlot.TextureMap = 'ModifiedBlueMarble.jpg';

Create XYPlot XYPlot1;
GMAT XYPlot1.SolverIterations = Current;
GMAT XYPlot1.UpperLeft = [ 0.1448516579406632 0.5113636363636364 ];
GMAT XYPlot1.Size = [ 0.5 0.4507575757575758 ];
GMAT XYPlot1.RelativeZOrder = 30;
GMAT XYPlot1.Maximized = false;
GMAT XYPlot1.XVariable = DefaultSC.ElapsedDays;
GMAT XYPlot1.YVariables = {DefaultSC.Earth.SMA};
GMAT XYPlot1.ShowGrid = true;
GMAT XYPlot1.ShowPlot = true;

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





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

BeginMissionSequence;
Propagate 'pro to periapsis' DefaultProp(DefaultSC) {DefaultSC.SolarPowerSystem1.ThrustPowerAvailable = 0.0, OrbitColor = [255 128 64]};

GillesMariotti
 
Posts: 6
Joined: Tue Feb 02, 2016 5:09 pm

Re: Propagate until eclipse

Postby jjkparker » Tue Feb 16, 2016 6:00 pm

Gilles, are you asking for a custom stopping condition? Such as, "propagate until myCustomVar = 3"?

If so, this is not currently a GMAT feature - see GMT-3857.
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: Propagate until eclipse

Postby GillesMariotti » Wed Feb 17, 2016 8:52 am

Yes, I would like to use a custom function within the propagator so a user variable can be updated automatically at each propagator step, like that request from OSIRIS.

Also, in a more general way, I wonder if it would be possible to add variables to the state vector of the equations of motion, along with their partial derivatives. But I guess that this is something that needs to be done at a source code level, not possible at the user (script or GUI) level.

Thanks Again
GillesMariotti
 
Posts: 6
Joined: Tue Feb 02, 2016 5:09 pm

Re: Propagate until eclipse

Postby jjkparker » Wed Feb 17, 2016 4:39 pm

Gilles, I think this second request would fall into the realm of a force model plugin (in C++). We have examples of those, see for example the SolarSail example plugin here: https://sourceforge.net/p/gmatplugins/g ... SolarSail/
Joel J. K. Parker
Flight dynamics engineer, GMAT team
http://gmatcentral.org
jjkparker
 
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD


Return to GMAT Resources

Who is online

Users browsing this forum: No registered users and 2 guests