Recent content by Sagekilla

  1. S

    Mathematica Taking only the positive sqrt in Mathematica

    As my title says, I need to take only the positive square root of some evaluation. For my calculation, the negative square root is extraneous. What I do is a normalization of a wave function: J = Integrate[Psi[x]^2, {x, 0, a}] sol = Solve[J == 1, A] A /. sol My only problem is those...
  2. S

    C/C++ Learn C++ Programming: Tutorials, Books & Notes for Beginners

    I'm a second year undergraduate in Physics and Computer Science, going into my third year. And like you, I have an interest in numerical simulations. I just posted a small tutorial on a basic numerical simulation of gravity. If they haven't moved it yet, (I posted it in the wrong forum by...
  3. S

    Intro to Gravitational Simulations

    Well, there's the tutorial! I hope this is helpful for all those who have a fascination with computers, physics, and simulations (as I do). If anyone has any comments, suggestions, or criticism feel free to post it or PM me. I will make changes as necessary to correct any errors I may have made.
  4. S

    Intro to Gravitational Simulations

    Simulating Gravity in an N-body Simulation So now we can solve the equations of motion for a system of bodies under mutual gravitational attraction. Our three equations to remember are: (1.13): \vec{F_{ji}} = \frac{-G M{i} M{j}}{r_{ji}^2} \hat{r_{ji}} (2.10): \vec{r}(t + dt) = \vec{r}(t) +...
  5. S

    Intro to Gravitational Simulations

    Solving the Equations of Motion Where do we go from here? We can calculate, for any object, the acceleration due to the gravitational force of any other object. How can we calculate how a pair of particles move through space? To do so, we need to make use of differential equations. To start...
  6. S

    Intro to Gravitational Simulations

    Finding the Gravitational Interaction To start with, I'll be talking about gravity. As is known, gravity is an attractive force between two masses. It's proportional to each of their masses, and inversely proportional to the square of the distance between the two objects. Gravity is also...
  7. S

    Intro to Gravitational Simulations

    Hi all, I recently was posting in another thread on how to properly integrate the equations of motion in gravitational simulations. I thought this would be a good opportunity to provide some basic knowledge on simulations, numerical differential equations, and a little bit of programming. I'm...
  8. S

    Calculating time derivative of Magnetic force

    Ah, thank you. My biggest issue with differentiating the above equations was trying to figure out how the the norm of a vector would differentiate with respect to a variable. I'll work these out and post my results.
  9. S

    Calculating time derivative of Magnetic force

    Well, if I start with something simple like the position unit vector: \frac{d}{dt}\hat{r} = \frac{d}{dt}\frac{\vec{r_{1}} - \vec{r_{2}}} {| \vec{r_{1}} - \vec{r_{2}} |} \frac{d}{dt}\hat{r} = \frac{|\vec{r_{1}} - \vec{r_{2}}| (\vec{v_{1}} - \vec{v_{2}}) - |\vec{r_{1}} -...
  10. S

    Calculating time derivative of Magnetic force

    Hi all, I ran into a bit of an issue trying to figure out how to properly differentiate the magnetic force due to particle interactions. To be specific, I'm actually looking for the time derivative of acceleration (jerk) due to the magnetic force, but it's essentially the same problem. For...
  11. S

    Position Derivative of Acceleration Due to Gravity

    I had a thought before and I'm not sure if this is meaningful to ask or even possible to ask but I'd figure it's worth a shot. Is it meaningful to take the position derivative of acceleration due to gravity? I'd imagine, at least intuitively, this sounds like it's possible. As you move along...
  12. S

    C/C++ Adaptive step size algorithm in c++ for runge kutta

    It looks like you're integrating slightly wrong. I wouldn't separate the Runge Kutta integration into x and y steps. You should solve for k1x = f(t, x) and k1y = f(t, y). Then, calculate k2x and k2y, and so forth. The idea is you want to make a complete approximation going forward. You're...
  13. S

    Solving differential equations using implicit methods

    Yes, there is. But what I was asking was if I could replace the derivative of f inside of Newton's method by f(t, f(t, y)), since for first order ODEs it would be equivalent to differentiating (at least I think it is) all the y components of differential equation. Because otherwise if I...
  14. S

    Solving differential equations using implicit methods

    Thanks for your help! I never understood how to properly apply Newton's method before. I implemented it as you had shown, with: z_{i+1} = z_{i} - \frac{z_{i} - y_{n} - hf(t_{n+1}, z_{i})}{1 - hf'(t_{n+1}, z_{i})} Is it safe to assume that I can say that: f'(t_{n+1}, z_{i}) = f(t_{n+1}...
  15. S

    Solving differential equations using implicit methods

    Hi all, I'm writing myself a ordinary differential equation solver and I've already implemented several explicit integrators, which were pretty easy for me to do. Now I've decided to work on some implicit methods (for any stiff equations) and I've run into some issues. The most basic one is...
Back
Top