0

I'm trying to use julia to solve a forced oscillator function my′′(t)+cy′(t)+ky(t)=−mg but im not sure how to set up the function for julia to solve it. m, c, k, and g are constants

I tried moving the -mg to the left side as I would to follow what I would've done to a homogeneous equation

1 Answers1

0

change it to y'' = -y and then use SecondOrderODEProblem, i.e. https://diffeq.sciml.ai/stable/types/dynamical_types/, via:

SecondOrderODEProblem((v,u,p,t)->-(p.c*v + p.k*u - p.m*p.g)/p.m, v0, u0,
                      (0.0,1.0), (c = ..., k = ..., m = ..., g = ...))

For more examples of this, see the Classical Physics Problems tutorial:

https://docs.sciml.ai/DiffEqDocs/stable/examples/classical_physics/

Chris Rackauckas
  • 18,645
  • 3
  • 50
  • 81