Report File and STM printing

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

Report File and STM printing

Postby marchand » Tue Jul 03, 2012 10:31 pm

I edited samples\Ex_LibrationPointStationKeeping_ESM.script and added a report file to it as listed below. The file propagates seven segments, each one targeting a specific crossing condition. I would like to be able to write a file that lists the STM at the end of each propagated segment along the trajectory. However, currently, the addition below only saves the initial state of each segment, not the propagated end-state. Thus, the only STM that ever gets printed to the report file is the identity matrix, since that gets re-initialized for each propagation. Do you have any suggestions on how to write the STM at arbitrary interior points along the segment including the end-state? or even just the STM at the end-state itself? Or is that functionality not currently supported inside the scripting environment?


Code: Select all
Create ReportFile ReportFile1;
GMAT ReportFile1.SolverIterations = Current;
GMAT ReportFile1.UpperLeft = [ 0 0 ];
GMAT ReportFile1.Size = [ 0 0 ];
GMAT ReportFile1.RelativeZOrder = 0;
GMAT ReportFile1.Filename = 'libration-example-state-and-stm.txt';
GMAT ReportFile1.Precision = 16;
GMAT ReportFile1.Add = {ACE.A1ModJulian, ACE.EarthMJ2000Eq.X, ACE.EarthMJ2000Eq.Y, ACE.EarthMJ2000Eq.Z, ACE.EarthMJ2000Eq.VX, ACE.EarthMJ2000Eq.VY, ACE.EarthMJ2000Eq.VZ, ACE.EarthMJ2000Eq.OrbitSTM};
GMAT ReportFile1.WriteHeaders = On;
GMAT ReportFile1.LeftJustify = On;
GMAT ReportFile1.ZeroFill = Off;
GMAT ReportFile1.ColumnWidth = 20;
GMAT ReportFile1.WriteReport = true;
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: Report File and STM printing

Postby shughes » Fri Jul 06, 2012 3:29 pm

Hi Belinda,

I attached a script that outputs the STM after each targeting loop. You can use the Report command to get output at specific points in a mission. You needed to have the 'STM' keyword in the Propagate line like this:

Code: Select all
Create ReportFile rf
Create String newRow
newRow = '';

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

BeginMissionSequence;
% Comment:  This is for simple example purposes and results in a Delta v
% that is much too high!  Delta V's should be on the order of cm/s.  The
% targeting scheme is beyond the scope of this simple demo. -SPH
For 'For I = 1:7' I = 1:1:7;
   Target 'Target Loop' DefaultDC {SolveMode = Solve, ExitMode = DiscardAndContinue};
      Vary 'Vary MCC.V' DefaultDC(MCC.Element1 = MCC.Element1, {Perturbation = 1e-5, Lower = -0.1, Upper = 0.1, MaxStep = 0.001});
      Maneuver 'Apply MCC' MCC(ACE);
      Propagate  EarthSunMoon(ACE,'STM') {ACE.EarthSunL1CS.Y = 0};
      Report rf newRow
      Report rf ACE.OrbitSTM
      Achieve 'Achieve VX = 0' DefaultDC(ACE.EarthSunL1CS.VX = 0, {Tolerance = 1e-005});
   EndTarget;  % For targeter DefaultDC
EndFor;


Steve
Attachments
Ex_LibrationPointStationKeeping_ESM.script
Added STM Output to Example Mission
(9.22 KiB) Downloaded 521 times
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Report File and STM printing

Postby marchand » Sat Jul 07, 2012 3:12 am

Thanks Steve, that worked great. I do have one follow-up question, if I may. Let's say I have a matlab function I want to send GMAT data to. Specifically, the STM after the Propagate command. I thought of two ways of doing that, neither of which work so I'm wondering if you can point me in the right direction.

I experimented with the idea using the matlab interface, first by adding these lines prior to the mission sequence:

Code: Select all
Create Variable fieldValue;
Create String fieldName;
fieldName = 'OrbitSTM'

Create MatlabFunction getfield;


Then added the lines below after the Propagate statement in your script.

Code: Select all
GMAT [fieldValue] = getfield(ACE.EarthMJ2000Eq,fieldName);
Report rfstates fieldValue;


Unfortunately, it really doesn't like those last two lines. It says the OrbitSTM field does not exist. Am I doing that wrong? Or is it just not possible to do that at all?

If not, is it possible, instead, to save the contents of OrbitSTM as a two-dimensional array in GMAT? Say, something like:

Code: Select all
Create Array STM[6,6];
STM = ACE.EarthMJ2000Eq.OrbitSTM;


I know that doesn't work, but I'm wondering if there's some variation of that which might. I was unable to do an element by element assignment because I'm not sure how to access the numerical values of ACE.EarthMJ2000Eq.OrbitSTM from the GMAT scripting environment.

Thank you!
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: Report File and STM printing

Postby shughes » Mon Jul 09, 2012 8:25 pm

You can assign the OrbitSTM to an array as shown below. You should then be able to send the array to MATLAB via a simple MATLAB function call. The snippet below does report the STM to the report but I did not write a MATLAB function and send the array to MATLAB. if that does not work it is a bug.

Code: Select all
Create Array mySTM[6,6]  % HERE IS INITIALIZATION OF THE ARRAY
BeginMissionSequence;
For 'For I = 1:7' I = 1:1:7;
   Target 'Target Loop' DefaultDC {SolveMode = Solve, ExitMode = DiscardAndContinue};
      Vary 'Vary MCC.V' DefaultDC(MCC.Element1 = MCC.Element1, {Perturbation = 1e-5, MaxStep = 0.001});
      Maneuver 'Apply MCC' MCC(ACE);
      Propagate  EarthSunMoon(ACE,'STM') {ACE.EarthSunL1CS.Y = 0};
      Report rf newRow;
      %Report rf ACE.OrbitSTM;
      mySTM = ACE.OrbitSTM;  % HERE IS THE ASSIGMENT TO AN ARRAY
      Report rf mySTM;       % HERE IS REPORT OF THE ASSIGNED ARRAY
      Achieve 'Achieve VX = 0' DefaultDC(ACE.EarthSunL1CS.VX = 0, {Tolerance = 1e-005});
   EndTarget;  % For targeter DefaultDC
EndFor;
Attachments
Ex_LibrationPointStationKeeping_ESM.script
Here is the full script that assigns STM to an array.
(9.37 KiB) Downloaded 495 times
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Report File and STM printing

Postby marchand » Tue Jul 10, 2012 4:10 pm

Steve,

Thanks. That's helpful. Now, as a follow-on to that, I would have thought I could also access the state vector in a similar fashion. If I look at the fields available in the Spacecraft object, aside from OrbitSTM, there doesn't seem to be a direct way to access the six-dimensional cartesian state vector, but it would seem that I can access the cartesian state elements. In this case, ACE.CartesianX, ACE.CartesianY, ..., ACE.CartesianVZ. However, I get an error when I try to access them in that form.

Shouldn't I be able to just say

Code: Select all
Create Variable X;


Then, in the mission sequence, say

Code: Select all
X = ACE.CartesianX;


Thanks again!

--Belinda
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: Report File and STM printing

Postby marchand » Tue Jul 10, 2012 4:21 pm

Nevermind! The error was elsewhere, the lines below were correct. Though, correct me if I am wrong, there is not way to return the six-dimensional state vector directly, right? You can only return the elements of the state vector as in my previous post; ACE.CartesianX, ACE.CartesianY, ... , ACE.CartesianVZ.

Also, I noticed that a coordinate frame is not a specification required for the propagators themselves. Does that mean that the propagation (i.e. the numerical integration) *always* proceeds in some default possibly inertial coordinate system, and that GMAT is only able to OUTPUT the state in other coordinate systems, even though the propagation always proceeds in the same frame?
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: Report File and STM printing

Postby shughes » Tue Jul 10, 2012 8:02 pm

marchand wrote:Nevermind! correct me if I am wrong, there is not way to return the six-dimensional state vector directly, right? You can only return the elements of the state vector as in my previous post; ACE.CartesianX, ACE.CartesianY, ... , ACE.CartesianVZ.


You are correct that there is not a one-line way to get the entire Cartesian State. This is really useful though and should be added to our list of new things to include.

marchand wrote:Also, I noticed that a coordinate frame is not a specification required for the propagators themselves. Does that mean that the propagation (i.e. the numerical integration) *always* proceeds in some default possibly inertial coordinate system, and that GMAT is only able to OUTPUT the state in other coordinate systems, even though the propagation always proceeds in the same frame?


GMAT integrates the equations of motion with respect to the central body defined on the propagator and in the Mean J2000 Equator axes. So the origin changes but the axes are the same for all propagations. The central body is important to avoid numerical issues of integrating a phobos orbit with the sun as the origin!!
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Report File and STM printing

Postby marchand » Tue Jul 10, 2012 9:04 pm

Thanks Steve. Here's some related questions, with some code attached.

(1) Just to clarify, when you say the propagation is always done relative to Mean J2000 Equator axes centered at the body, do you mean the Earth Mean Equator and Equinox of J2000? Let me pose the question in a specific context. When I do a propagation, outside of GMAT, I will often do so in a body centered frame, where the reference axes are consistent with those of the Earth Mean Equator and Equinox of J2000 (the reference frame for the DE405 ephemeris). Is that consistent with how GMAT does the propagation?

(2) Following that train of thought, is it safe to say then that it is currently not possible for GMAT to perform a numerical integration in terms of rotating coordinate systems then? For instance, in multi-body systems, a synodic rotating frame is often the frame of integration, not just the frame in which the data is displayed. This approach is often desirable due to the dynamically sensitive nature of the problem. Just want to confirm, once again, that this is not a capability currently supported.

(3) The attached script includes some lines after the EndTarget line which store the spacecraft state and state transition matrix at the end of the propagated trajectory segment. Since the trajectory spans over seven segments, the arrays have seven rows. The patchState array is of dimension 7x6, each of the six columns represents one state: X, Y, Z, VX, VY, VZ. The patchSTMs array is of dimension 7x36, and each column consists of one element of the STM. The patchSTMs array was filled in column order format. I'd also like to store the time at the end of each propagated segment. In a trial and error first attempt, I added line #275 to the script, which is currently commented out because it causes an error during execution. Apparently, I am unable to access the Epoch field, even though that is listed as one of the spacecraft object fields in Spacecraft.cpp. Is there a way to procure that information within the GMAT scripting environment?

(4) I noticed, by looking at the output files generated by the script, that the elements of the STM continue to grow with each propagation. Thus, I'm inclined to think that the STM is not "Reset" each time the propagator is called in this example. I had noted, earlier on, that there is a method in the Spacecraft.cpp class called TakeAction, and one of the actions listed is ResetSTM. However, a recursive grep search through the entire source tree reveals that this action is never referenced by any classes, which confirms my suspicion that the STM is never reset during the propagation. I'd still like confirmation, if you can, that this is the case.

Thanks :-)
Attachments
Ex_LibrationPointStationKeeping_ESM_bgmp.script
(10.1 KiB) Downloaded 522 times
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: Report File and STM printing

Postby marchand » Tue Jul 10, 2012 9:08 pm

Clarifying question (1), I can do a Moon Centered integration - for example - where the propagator uses coordinates associated with the Earth Mean Equator and Equinox of J2000, as opposed to the central body's Mean Equator. That's just a simple origin shift, basically, as opposed to a full coordinate transformation.
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: Report File and STM printing

Postby marchand » Thu Jul 12, 2012 4:49 am

Please disregard question #3 below, I think I just found the answer in a round about way. Though it wasn't immediatley obvious at first, apparently the following fields are accessible via the spacecraft object as real time parameters: "ElapsedDays", "ElapsedSec", "CurrA1MJD", "A1ModJulian", "TAIModJulian", "TTModJulian", "TDBModJulian", "UTCModJulian".





marchand wrote:Thanks Steve. Here's some related questions, with some code attached.

(1) Just to clarify, when you say the propagation is always done relative to Mean J2000 Equator axes centered at the body, do you mean the Earth Mean Equator and Equinox of J2000? Let me pose the question in a specific context. When I do a propagation, outside of GMAT, I will often do so in a body centered frame, where the reference axes are consistent with those of the Earth Mean Equator and Equinox of J2000 (the reference frame for the DE405 ephemeris). Is that consistent with how GMAT does the propagation?

(2) Following that train of thought, is it safe to say then that it is currently not possible for GMAT to perform a numerical integration in terms of rotating coordinate systems then? For instance, in multi-body systems, a synodic rotating frame is often the frame of integration, not just the frame in which the data is displayed. This approach is often desirable due to the dynamically sensitive nature of the problem. Just want to confirm, once again, that this is not a capability currently supported.

(3) The attached script includes some lines after the EndTarget line which store the spacecraft state and state transition matrix at the end of the propagated trajectory segment. Since the trajectory spans over seven segments, the arrays have seven rows. The patchState array is of dimension 7x6, each of the six columns represents one state: X, Y, Z, VX, VY, VZ. The patchSTMs array is of dimension 7x36, and each column consists of one element of the STM. The patchSTMs array was filled in column order format. I'd also like to store the time at the end of each propagated segment. In a trial and error first attempt, I added line #275 to the script, which is currently commented out because it causes an error during execution. Apparently, I am unable to access the Epoch field, even though that is listed as one of the spacecraft object fields in Spacecraft.cpp. Is there a way to procure that information within the GMAT scripting environment?

(4) I noticed, by looking at the output files generated by the script, that the elements of the STM continue to grow with each propagation. Thus, I'm inclined to think that the STM is not "Reset" each time the propagator is called in this example. I had noted, earlier on, that there is a method in the Spacecraft.cpp class called TakeAction, and one of the actions listed is ResetSTM. However, a recursive grep search through the entire source tree reveals that this action is never referenced by any classes, which confirms my suspicion that the STM is never reset during the propagation. I'd still like confirmation, if you can, that this is the case.

Thanks :-)
marchand
 
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Next

Return to GMAT Resources

Who is online

Users browsing this forum: No registered users and 1 guest

cron