Skip to content

Commit f2921b0

Browse files
authored
Update psys.c
1 parent be63c14 commit f2921b0

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/psys.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ PlanetarySystem *AllocPlanetSystem(int nb) {
2121
char command[512];
2222
real *mass, *x, *y, *z, *vx, *vy, *vz, *acc;
2323
boolean *feeldisk, *feelothers;
24+
boolean *flag_pres;
2425
int i;
2526
PlanetarySystem *sys;
2627
int temp;
@@ -45,7 +46,8 @@ PlanetarySystem *AllocPlanetSystem(int nb) {
4546
}
4647
feeldisk = (boolean*)malloc(sizeof(char)*(nb+1));
4748
feelothers = (boolean*)malloc(sizeof(char)*(nb+1));
48-
if ((feeldisk == NULL) || (feelothers == NULL)) {
49+
flag_pres = (boolean*)malloc(sizeof(char)*(nb+1));
50+
if ((feeldisk == NULL) || (feelothers == NULL) || (flag_pres == NULL)) {
4951
fprintf (stderr, "Not enough memory for boolean allocation in PlanetarySystem.\n");
5052
prs_exit (1);
5153
}
@@ -59,9 +61,11 @@ PlanetarySystem *AllocPlanetSystem(int nb) {
5961
sys->mass = mass;
6062
sys->FeelDisk = feeldisk;
6163
sys->FeelOthers = feelothers;
64+
sys->Flag_Pres = flag_pres;
6265
for (i = 0; i < nb; i++) {
6366
x[i] = y[i] = z[i] = vx[i] = vy[i] = vz[i] = mass[i] = acc[i] = 0.0;
6467
feeldisk[i] = feelothers[i] = YES;
68+
flag_pres[i] = NO;
6569
}
6670
for (i = 0; i < nb; i++) {
6771
/* Creates orbit[i].dat if it does not exist */
@@ -111,6 +115,7 @@ void FreePlanetary () {
111115
free (Sys->acc);
112116
free (Sys->FeelOthers);
113117
free (Sys->FeelDisk);
118+
free (Sys->Flag_Pres);
114119
free (Sys);
115120
}
116121

@@ -140,7 +145,7 @@ real ComputeInnerMass(real r) {
140145

141146
PlanetarySystem *InitPlanetarySystem (char *filename) {
142147
FILE *input;
143-
char s[512], nm[512], test1[512], test2[512], *s1;
148+
char s[512], nm[512], test1[512], test2[512], test3[512], *s1;
144149
PlanetarySystem *sys;
145150
int i=0, j, nb, nbstars=0, i_star1=-1, i_star2=-1;
146151
real xp,yp,zp,vxp,vyp,vzp,mp,M1,M2,r1,r2,v1,v2;
@@ -171,9 +176,9 @@ PlanetarySystem *InitPlanetarySystem (char *filename) {
171176
if (isalpha(s[0])) {
172177
s1 = s + strlen(nm);
173178
#ifdef FLOAT
174-
sscanf(s1 + strspn(s1, "\t :=>_"), "%f %f %f %s %s", &dist, &mass, &accret, test1, test2);
179+
sscanf(s1 + strspn(s1, "\t :=>_"), "%f %f %f %s %s %s", &dist, &mass, &accret, test1, test2, test3);
175180
#else
176-
sscanf(s1 + strspn(s1, "\t :=>_"), "%lf %lf %lf %s %s", &dist, &mass, &accret, test1, test2);
181+
sscanf(s1 + strspn(s1, "\t :=>_"), "%lf %lf %lf %s %s %s", &dist, &mass, &accret, test1, test2, test3);
177182
#endif
178183
if ((SEMIMAJORAXIS > 0.0) && (i == 0)) // SemiMajorAxis can be
179184
// used to overwrite the
@@ -191,8 +196,10 @@ PlanetarySystem *InitPlanetarySystem (char *filename) {
191196
if (PLANETMASS > 1e-18)
192197
sys->mass[0] = PLANETMASS;
193198
feeldis = feelothers = YES;
199+
flag_pres = NO;
194200
if (tolower(*test1) == 'n') feeldis = NO;
195201
if (tolower(*test2) == 'n') feelothers = NO;
202+
if (tolower(*test3) == 'y') flag_pres = YES;
196203
sys->x[i] = (real)dist*(1.0+ECCENTRICITY); // Planets are initialized at apoastron
197204
sys->y[i] = 0.0;
198205
sys->z[i] = 0.0;

0 commit comments

Comments
 (0)