Skip to content

Unknown Function (GaussProblemUVF) in VinfVectorFunc.m #1

@poutasse

Description

@poutasse

@BrendanLuke15 I am trying to use your repository to generate a Porkchop plot for an Earth-Mars mission. The VinfVectorFunc.m function contains a call to some function called GaussProblemUVF -- [V1,V2,~] = GaussProblemUVF(State1(i,:),State2(i+j-1,:),TOF(j)); -- which is not included in the repository. I assume that this function is used to solve the Lambert problem, so I tried using another published Lambert solver (link), but my plots don't match up with those I've seen you publish on Space Stack Exchange, such as (link). The changes I made to VinfVectorFunc.m to allow for use of (this) Lambert solver are shown below:

function [Vinf1,Vinf2] = VinfVectorFunc(State1,State2,Date1,Date2,TOF,GM_central)
% Function to simplify data generation for interplanetary transfers:
% Inputs:
%   - State1: state vector for departure planet
%   - State2: state vector for arrival planet
%   - Date1: date vector for departure dates
%   - Date2: date vector for arrival dates
%   - TOF: time of flight vector (s)
%   - GM_central: std gravitational parameter of central body (ADDED BY ME)
% Outputs:
%   - Vinf1: vector and magnitude for departure Vinfs
%   - Vinf2: vector and magnitude for arrival Vinfs

Vinf1 = NaN(length(Date1),length(Date2),4);
Vinf2 = NaN(length(Date1),length(Date2),4);

startTime = toc;
for i = 1:length(Date1)
    for j = 1:length(TOF)
        %[V1,V2,~]  = GaussProblemUVF(State1(i,:),State2(i+j-1,:),TOF(j));
        % Modification by me to use a different lambert solver
        TOF_days = TOF/86400;
        [V1,V2,~] = lambert(State1(i,1:3),State2(i+j-1,1:3),TOF_days(j),0,GM_central);
        % X,Y,Z Vinf componenents
        Vinf1(i,i+j-1,1:3) = V1 - State1(i,4:6);
        Vinf2(i,i+j-1,1:3) = V2 - State2(i+j-1,4:6);
        % Vinf magnitude
        Vinf1(i,i+j-1,4) = sqrt(Vinf1(i,i+j-1,1)^2+Vinf1(i,i+j-1,2)^2+Vinf1(i,i+j-1,3)^2);
        Vinf2(i,i+j-1,4) = sqrt(Vinf2(i,i+j-1,1)^2+Vinf2(i,i+j-1,2)^2+Vinf2(i,i+j-1,3)^2);
    end
    % Report Progress:
    % fprintf('Progress:\n %.4f %%\n',i/length(Date1)*100);
    % fprintf('Time Elapsed (mins):\n %.4f \n',(toc-startTime)/60);
    % fprintf('Time Remaining Estimate (mins):\n %.4f \n',(toc-startTime)/(i/length(Date1))/60-(toc-startTime)/60);
    % fprintf('Total Time Estimate (mins):\n %.4f \n',(toc-startTime)/(i/length(Date1))/60);
end

end

I then used the following function call in InterplanetaryTransfers.m:
[VinfA,VinfB] = VinfVectorFunc(Planets.State{i-1},Planets.State{i},Planets.Dates{i-1},Planets.Dates{i},Planets.TOF{i},mu_Sun);
Would you be willing to provide your code for the GaussProblemUVF function or discuss what needs to be modified to make the other solver work? Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions