-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathisdCore.c
executable file
·64 lines (54 loc) · 1.63 KB
/
isdCore.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "isdCore.h"
int readLorenzDataFile(
char * filePath,
Lorenz * lorenzData
)
{
FILE *f;
initializeNonParameters(lorenzData);
if((f = fopen(filePath,"r+"))==NULL)
return ERRORISDGL;
fscanf(f,"ro: %lf\nsigma: %lf\nbeta: %lf\ndt: %lf\nmaxiters: %d\ncolorscheme: %d\nstyle: %d",&lorenzData->ro,&lorenzData->sigma,
&lorenzData->beta,&lorenzData->dt,&lorenzData->maxiters,
&lorenzData->scheme, &lorenzData->style);
if(DEBUG)
printf("ro: %lf\nsigma: %lf\nbeta: %lf\ndt: %lf\nmaxiters: %d\ncolorscheme: %d\nstyle: %d\n",lorenzData->ro,lorenzData->sigma,
lorenzData->beta,lorenzData->dt,lorenzData->maxiters,
lorenzData->scheme, lorenzData->style);
fclose(f);
return SUCCESSISDGL;
}
void defaultLorenzValues(
Lorenz * lorenzData
)
{
initializeNonParameters(lorenzData);
sscanf("28 10 2.667","%lf %lf %lf",&lorenzData->ro, &lorenzData->sigma, &lorenzData->beta);
sscanf("0.02","%lf",&lorenzData->dt);
lorenzData->maxiters = 30000;
lorenzData->scheme = 1;
lorenzData->style = 1;
}
void initializeNonParameters(
Lorenz * lorenzData
)
{
lorenzData->x=3.f;
lorenzData->y=15.f;
lorenzData->z=1.f;
lorenzData->t=0.f;
}
void doLorenzStep(
Lorenz * lorenzData
)
{
double _x=0.f,_y=0.f,_z=0.f;
_x = lorenzData->x + lorenzData->dt*lorenzData->sigma*(lorenzData->y-lorenzData->x);
_y = lorenzData->y + lorenzData->dt*(lorenzData->x*(lorenzData->ro-lorenzData->z)-lorenzData->y);
_z = lorenzData->z + lorenzData->dt*(lorenzData->x*lorenzData->y-lorenzData->beta*lorenzData->z);
lorenzData->x = _x;
lorenzData->y = _y;
lorenzData->z = _z;
if(DEBUG)
printf("x: %lf y: %lf z: %lf\n",_x,_y,_z);
}