Data from 2nd order ode mathematica

In summary, the conversation is about extracting time data from a system of 2nd order ODEs in Mathematica. The code provided involves numerical simulation of the 2-body problem, with inputs such as initial position and velocity, time period, and gravitational parameters. A plot of the trajectory relative to Earth is also shown. Suggestions are given for adding points and labels to the plot, as well as providing numerical results using the TableForm function.
  • #1
Dustinsfl
2,281
5
How can I extract time data from a system 2nd order ODEs in Mathematica?
 
Physics news on Phys.org
  • #2
Can you post the ODE's and your Mathematica code so far?
 
  • #3
Ackbach said:
Can you post the ODE's and your Mathematica code so far?

Code:
Numerical Simulation of the 2-Body Problem

ClearAll["Global`*"];

We begin with of the the necessary data for this problem...

M = 5974*10^21; (* mass of Earth, kg *)

m = 1000; (* mass of  spacecraft , kg *)

\[Mu] = 3.986*10^5; (* gravitaional parameter, based on km units of length, \
km/s for velocity *)

Rearth = 6378; (* radius of the Earth, km *)Simulation Inputs

r0 = {3950.55, 43197.9, 0};(* initial position vector, km *)
v0 = {3.3809, -7.25046, 0}; (* initial velocity vector, km *)
Days = 1/10; (* elapsed time of simulation days *)

\[CapitalDelta]t = Days*24*3600;(* convert elapsed days to seconds *)

s = NDSolve[
   {
    x1''[t] == -(\[Mu]/(Sqrt[x1[t]^2 + x2[t]^2 + x3[t]^2])^3)*x1[t],
    x2''[t] ==  -(\[Mu]/(Sqrt[x1[t]^2 + x2[t]^2 + x3[t]^2])^3)*x2[t],
    x3''[t] ==  -(\[Mu]/(Sqrt[x1[t]^2 + x2[t]^2 + x3[t]^2])^3)*x3[t],
    
    x1[0] == r0[[1]], (* intial x-position of satellite *)
    
    x2[0] == r0[[2]],(* intial y-position of satellite *)
    
    x3[0] == r0[[3]],(* intial y-position of satellite *)
    
    x1'[0] == v0[[1]],(* intial vx-rel of satellite *)
    
    x2'[0] == v0[[2]],(* intial vy-rel of satellite *)
    
    x3'[0] == v0[[3]](* intial vy-rel of satellite *)
    
    },
   {x1, x2, x3},
   {t, 0, \[CapitalDelta]t} 
   ];

Plot of the Trajectory Relative to Earth

g1 = ParametricPlot3D[
   Evaluate[{x1[t], x2[t], x3[t]} /. s], {t, 0, \[CapitalDelta]t},  
   PlotStyle -> {Red, Thick}];
g2 = Graphics3D[{Blue, Opacity[0.6], Sphere[{0, 0, 0}, Rearth]}];Show[g2, g1, Boxed -> False]
 
  • #4
I'm not certain exactly what you are expecting when you "extract time data", but perhaps something in this will help.What if you replaceShow[g2, g1, Boxed -> False]

with

g3 = Graphics3D[Table[Point[{x1[t], x2[t], x3[t]} /. s[[1]]], {t, 0, Δt, Δt/10}]];
g4 = Graphics3D[Table[Text[ToString[t], {x1[t], x2[t], x3[t]} /. s[[1]], {1, 0}], {t, 0, Δt, Δt/10}]];
Show[g2, g1, g3, g4, Boxed -> False]That will place points along your path and label each point with the associated value of t. You can adjust the step size and the label position next to each point as needed.

If that doesn't provide you with the necessary level of detail then you might try using

Table[{t,x1[t],x2[t],x3[t]}/.s[[1]], {t,0,Δt,Δt/10}]//TableForm

with appropriate step size to give you the numerical results to go along with your plot.
 
  • #5


To extract time data from a system of 2nd order ODEs in Mathematica, you can use the "NDSolve" function to solve the system and generate a numerical solution. This function allows you to specify the time range for which you want to solve the system, and then outputs the solution as a list of data points at different time intervals. You can then use the "Part" function to extract the time data from this list and use it for further analysis or plotting. Additionally, you can also use the "Table" function to generate a table of time and corresponding solution values, giving you more control over the time data extraction process.
 

Related to Data from 2nd order ode mathematica

1. What is a 2nd order ODE in Mathematica?

A 2nd order ODE (ordinary differential equation) in Mathematica is an equation that involves a function, its first derivative, and its second derivative. It is a mathematical model used to describe a process or system in terms of rates of change.

2. How is data from a 2nd order ODE in Mathematica analyzed?

Data from a 2nd order ODE in Mathematica is typically analyzed by plotting the solution to the equation, as well as examining the behavior of the solution at different values of the input variables. Other methods, such as numerical integration, can also be used to analyze the data.

3. What is the significance of solving a 2nd order ODE in Mathematica?

Solving a 2nd order ODE in Mathematica allows for a deeper understanding of the underlying system or process being modeled. It also allows for the prediction of future behavior and the ability to manipulate the system through adjusting input variables.

4. Can a 2nd order ODE in Mathematica be used for real-world applications?

Yes, a 2nd order ODE in Mathematica can be used for real-world applications in fields such as physics, engineering, and economics. It can be used to model and analyze a wide range of systems and processes, from simple harmonic motion to complex biological systems.

5. What are some common techniques for solving a 2nd order ODE in Mathematica?

Some common techniques for solving a 2nd order ODE in Mathematica include separation of variables, variation of parameters, and using Laplace transforms. Numerical methods, such as Euler's method and Runge-Kutta methods, can also be used to approximate solutions to the equation.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
475
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
924
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
300
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top