Troubles making a model of solarsail

I am currently working on a model to visualize/calculate the flight path of a solar sail (a type of spacecraft). But I have troubles with making the orbit of the spacecraft dependent on physics calculations.
Whenever I integrate these updating values the motion of the spacecraft freezes. Any suggestions?

float alpha = 0;
float tetha = 0;
float delta = 0;
float AU = 0.1496E12; //m
float d_sun = 6.963E8; //m
float d_earth = 6.371E6; //m
float d_moon = 1.738E6; //m
//float m_sun = ;
float m_earth = 5.972E24; //kg
//float m_moon = ;
float r_sun_earth = 0.1496E12; //m
float r_earth_moon = 384.4E6; //m
float r_sc = 42.164E6; //m
float t = 0; //sec
float dt = 60;
float a = 0; //ms2
float N_eff = 1;
float c = 2.99792458E8; //ms
float S = 1368; //wm2
float A = 1; //m2
float m = 1.33; //kg
float G = 6.67384E-11;
float v = 3.075E3; //ms

void setup () {
size(1700,1000);
noStroke();
frameRate(120);
background(0);
loop();
}

void draw() {
  float AU_factor = (0.01*AU)/1700;
float x_moon = width / 2 + cos(alpha) * r_earth_moon/AU_factor;
float y_moon = height / 2 + sin(alpha) * r_earth_moon/AU_factor;

//draws the celestial bodies
ellipse (x_moon,y_moon,d_moon/AU_factor,d_moon/AU_factor);
ellipse (width / 2,height/2,d_earth/AU_factor,d_earth/AU_factor);
ellipse (width / 2,(height/2)+AU,d_sun/AU_factor,d_sun/AU_factor);

alpha=alpha+0.05;
//draws the s/c
float x_sc = width / 2 + cos(tetha) * r_sc/AU_factor;
float y_sc = height / 2 + sin(tetha) * r_sc/AU_factor;

ellipse (x_sc,y_sc,1,1);

//tetha = ((TWO_PI*v)/(TWO_PI*r_sc));
float line_sun_sc = dist(width/2,(height/2)*AU,x_sc,y_sc);
float P = (S/c)*pow((line_sun_sc/AU),2);
a = a+((2*P*A*N_eff*pow(cos(delta),2))/m);
v = v+a*dt;
r_sc = (pow(v,2))/(G*m_earth); 
float tetha_t = (2*PI*r_sc)/v;
tetha = (2*PI)/tetha_t;
}

Hello. It looks like your code is missing some variable declarations (among other issues). It doesn’t run in Processing as it is. Would you mind posting a functional version? It would make it easier to help you.

1 Like

Hello. I have talked to my physics teacher and he said that I have to set up the rules differently. Therefore I am abandoning this code. Thank for your willingness to help me.