- #1

platipo

- 14

- 0

anyway, here's the "relevant" code, the function that I'm iterating over time.

Code:

```
void next(void){
int n;
double xw[CAR_NUMBER+1],uw[CAR_NUMBER+1];
double C=AMPLI/OMEGA;
u[CAR_NUMBER] = U0+AMPLI*cos(PI*OMEGA*t);
x[CAR_NUMBER] = U0*t+C*sin(PI*OMEGA*t);
// the first car in the cue is accelerating and braking periodically to perturbate the cue
Force(x,u,t+dt/2);
//the Force function returns a[n] which is the acceleration, I know it works, it gives no problem at all with the euler method
fprintf(fpx,"%10.3lf ",a[CAR_NUMBER-1]);
for( n=0; n<CAR_NUMBER; n++ ){
xw[n]= x[n] +u[n]*dt/2;
uw[n]= u[n] +a[n]*dt/2;
}
//end of the trial step
Force(xw,uw,t+dt);
for( n=0; n<CAR_NUMBER; n++ ){
x[n]= x[n] +uw[n]*dt;
u[n]= u[n] + a[n]*dt;
}
//end of the second and final step
t=t+dt;
}
```

whenever I run this, the car after the first (which is of course just oscillating) brakes pretty hard, and quickly becomes stationary, with all the ones following reasonably doing the same. I Thank you in advance for any possible help, I found out about this forum just a couple of days ago and I find it really great. Sorry for my poor english, I'm doing my best...