need help from physicists with my calculation methods in the solar system

Hey guys, I´m Theresa, student of Visual Communication in Germany, so English is not my native language and I am new in processing but I will try my best, so here is my question. I try to simulate a moving solar system in processing with all physically components like gravitation, forces, velocity, acceleration, positions etc. the coordinates I got from the nasa website. Please, could anyone help me with the calculations and correct them? Till monday, please :)

/////// SONNE zum 1.1. 2000
/////// X = -7.139143380212697E-03 Y = -2.792019770161695E-03 Z = 2.061838852554664E-04
/////// VX= 5.374260940168566E-06 VY=-7.410965396701423E-06 VZ=-2.522925180072137E-03

/////// MERKUR zum 1.1. 2000
/////// X =-1.478672233442572E-01 Y =-4.466929775364947E-01 Z =-2.313937582786785E-02
/////// VX= 2.117424563261189E-02 VY=-7.105386404267509E-03 VZ=-2.522925180072137E-03

/////// VENUS zum 1.1. 2000
/////// X =-7.257693602841776E-01 Y =-2.529582082587794E-02 Z = 4.137802526208009E-02
/////// VX= 5.189070188671265E-04 VY=-2.031355258779472E-02 VZ=-3.072687386494688E-04

/////// ERDE zum 1.1. 2000
/////// X =-1.756637922977122E-01   Y = 9.659912850526895E-01   Z = 2.020629118443605E-04
/////// VX=-1.722857156974862E-02   VY=-3.015071224668472E-03   VZ=-5.859931223618532E-08

/////// MARS zum 1.1. 2000
/////// X = 1.383221922520998E+00 Y =-2.380174081741852E-02 Z =-3.441183028447500E-02
/////// VX= 7.533013850513376E-04 VY= 1.517888771209419E-02 VZ= 2.996589710207392E-04

/////// https://rechneronline.de/planeten/masse.php

import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;

Boid Merkur = new Boid(
  new PVector(-1.478672233442572E-01, -4.466929775364947E-01, -2.313937582786785E-02), 
  new PVector(2.117424563261189E-02, -7.105386404267509E-03, -2.522925180072137E-03), 
  new PVector(0, 0, 0), 
  1.66060697e-7, 
  0.999, 
  100);


Boid Venus = new Boid(
  new PVector(-7.257693602841776E-01, -2.529582082587794E-02, 4.137802526208009E-02), 
  new PVector(5.189070188671265E-04, -2.031355258779472E-02, -3.072687386494688E-04), 
  new PVector(0, 0, 0), 
  0.000002448, 
  0.999, 
  155);

Boid Erde = new Boid(
  new PVector(-1.756637922977122E-01, 9.659912850526895E-01, 2.020629118443605E-04), 
  new PVector(-1.722857156974862E-02, -3.015071224668472E-03, -5.859931223618532E-08), 
  new PVector(0, 0, 0), 
  0.000002988, 
  0.999, 
  255); 

Boid Mars = new Boid(
  new PVector(1.383221922520998E+00, -2.380174081741852E-02, -3.441183028447500E-02), 
  new PVector(7.533013850513376E-04, 1.517888771209419E-02, 2.996589710207392E-04), 
  new PVector(0, 0, 0), 
  3.22772875e-7, 
  0.999, 
  100);

PeasyCam cam;

void setup() {
  size(1600, 1200, P3D);
  background(150);
  frameRate(26);
  cam = new PeasyCam(this, 10000);
}


void draw() {
  background(0);
  lights();
  translate(width / 2, height / 2);
  fill(255, 215, 0);
  sphere(170);
  scale(2000);
  Merkur.bewegDich();
  Merkur.zeichneDich(0.01);
  Venus.bewegDich();
  Venus.zeichneDich(0.01);
  Erde.bewegDich();
  Erde.zeichneDich(0.01);
  Mars.bewegDich();
  Mars.zeichneDich(0.01);
}



class Boid {
  PVector pos;
  PVector vel;
  PVector acc;
  float mas;
  float deltaT;
  float far;

  Boid(PVector position, PVector velocity, PVector acceleration, float masse, float deltaZeit, float farbe) {
    pos = position;
    vel = velocity;
    acc = acceleration;
    mas = masse;
    deltaT = deltaZeit;
    far = farbe;
  }

  void bewegDich() {
    PVector posS = new PVector();
    float masS = 1;                                     // Sonne in Sonnenmassen
    float G_SI = 6.674E-11;                             // m^3 kg^-1 s^-2
    float sekundenTag;
    float kiloSonnenmassen;
    float meterAE;
    float Grav;

    float r = PVector.dist(posS, pos);                  
    sekundenTag = (24 * 60 * 60);
    kiloSonnenmassen = 1.98892E+30;
    meterAE = (1 / (1.49597E+11));
    Grav = (G_SI * (sekundenTag * sekundenTag) * kiloSonnenmassen * (meterAE * meterAE * meterAE));               // 0.017204072^2
    PVector Anziehungskraft = (PVector.sub(posS, pos)).mult(Grav * mas * masS * (1 / (r * r * r)));               // anziehungskraft der sonne

    acc = PVector.div(Anziehungskraft, mas);
    vel = PVector.add(vel, (acc.mult(deltaT)));
    pos = PVector.add(pos, vel);                                                                                  // DIE GESCHWINDIGKEIT WIRD AUF DIE POSITION AUFADDIERT
    acc = PVector.mult(acc, 0);
  }

  void zeichneDich(float groesse) {
    println(pos);
    pushMatrix();                                       // ändert die koordinaten innerhalb von push/pop matrix
    translate(pos.x, pos.y, pos.z);
    fill(far);
    noStroke();
    sphere(groesse);
    popMatrix();
  }
}

Answers

  • please don't post duplicates, you'll just confuse people.

  • it is no duplicate. it is an edited version and a problem concerning the calculations inside the class, because this question isn't answered.

  • then comment on and close the other one. preferably with a link to this new one so people can follow.

    my big question is what is the problem? you don't say. and when i run the code it looks like planets orbiting a sun. isn't that what you want?

  • edited November 2017

    oh, ok the problem is, that in my calculation is missing a variable. my lecturer told me, if I calculate the position (in line 124) I have to multiply the velocity with deltaT. but if I do this, my simulation is crashing. the other point is, that I still don't understand the value of deltaT. I don't know which value it has to be and why. and could anyone tell me what I have to write in a for loop that the program runs a determinate time and then stops the simulation? I have to tell the program how long is one earth year and then "run x earth years" right?

  • vel = PVector.add(vel, (acc.mult(deltaT)));
    

    couple of things here

    a.add(b); // adds b to a, similar to a += b
    
    a = PVector.add(b, c);  // like a = b + c
    

    so where you have vel = PVector.add(vel, (acc.mult(deltaT))); you are modifying vel AND acc

    but line 124, the obvious change is to make it

    pos = PVector.add(pos, vel.mult(deltaT)); // pos = pos + (vel *= deltaT) = WRONG
    

    this changes pos AND vel, which you don't want.

    try

    pos.add(PVector.mult(vel, deltaT)); // pos += (vel * deltaT) = better
    
  • line 125 does nothing.

Sign In or Register to comment.