diff --git a/apitest/apitest.c b/apitest/apitest.c index 26599805d41db087ae79b48262bf9cff99a7b5d7..de2150f52dffb694b4cb65a6cb696f907dc7b53d 100644 --- a/apitest/apitest.c +++ b/apitest/apitest.c @@ -130,6 +130,12 @@ int main ( int argc, char * * argv ) &store, &argstring, -1); + fprintf(stderr, + "stardata[%d] = %p; preferences %p\n", + i, + stardata[i], + stardata[i]->preferences); + /* log to APITEST_OUTPUT_STREAM */ strlcpy(stardata[i]->preferences->log_filename, diff --git a/configure b/configure index b4b8766a345076b0123b94b92600f97c4f81a596..75d9857c0aff2be77515891cbafa0c08d2b9e04a 100755 --- a/configure +++ b/configure @@ -1207,9 +1207,10 @@ sub features undef, pkg_config => 'gsl', backup_libs => '-lgsl -lgslcblas', - version => + version => undef, required_version => 2.4, required_libs => ['gsl','gslcblas'], + warn_string => "binary_c looks for the libgsl shared in the usual places your system looks, as well as \$HOME/gsl (which I think is at $ENV{HOME}/gsl), but you can also set the environment variable GSL_DIR to point to the location of libgsl.\n", }, have_libbacktrace => @@ -1304,8 +1305,9 @@ sub features { check => 1, version => join('.',($^V=~/v(\d+)\.(\d+)/)), + require_version => 5.16, warn_version => 5.16, - warn_string => "**** Warning: Perl 5.16 and above is required to use binary_grid : please see doc/binary_grid-flexigrid.pdf for details *****\n", + warn_string => "**** Warning: Perl 5.16 and above is required to use binary_grid and is recommended in general : please see doc/binary_grid-flexigrid.pdf for details *****\n", }, # CPU frequency information @@ -1405,11 +1407,14 @@ sub features # remove features that fail their checks foreach my $feature (sort keys %$features) { - if(!$features->{$feature}->{check}) + my $f = $features->{$feature}; + if(!($f->{check} || + defined $f->{required_version} || + defined $f->{require_libs}) + ) { delete $features->{$feature}; } - my $f = $features->{$feature}; if($f->{required_libs}) { foreach my $lib (@{$f->{required_libs}}) @@ -1417,6 +1422,7 @@ sub features if(!checklib('lib'.$lib)) { print "library $lib not found: it is required! To solve this problem, either install the library, check it is in your library paths (e.g. LD_LIBRARY_PATH and LIBRARY_PATH) or fix the checklib() function in this configure script so that it works properly on your architecture.\n"; + print $f->{warn_string} if($f->{warn_string}); exit; } } @@ -1455,11 +1461,14 @@ sub features { print "you either have an inferior version or do not have this installed\n"; } + print $f->{warn_string} if($f->{warn_string}); } } + #print "Feature $feature : $f->{required_version}\n"; if(defined $f->{required_version} && - $f->{version} < $f->{required_version}) + $f->{version} < $f->{required_version} + ) { print "Version $f->{required_version} of $feature is required : "; if($f->{version}=~/\d/) @@ -1470,6 +1479,7 @@ sub features { print "you either have an inferior version or do not have this installed\n"; } + print $f->{warn_string} if($f->{warn_string}); exit; } diff --git a/doc/binary_c-RLOF.pdf b/doc/binary_c-RLOF.pdf index 0147986e5785ba590f6ccc7b89b33f1207b6b380..2ad1cca9a8bbd90d5c4758c6f0efa27ff8474f0c 100644 Binary files a/doc/binary_c-RLOF.pdf and b/doc/binary_c-RLOF.pdf differ diff --git a/doc/binary_c2.pdf b/doc/binary_c2.pdf index 07c0058599b4421e2ecb2614ec3f7b65d3a21b5c..b2c4084d7d0b6840c6bfccb3d1edc4e0ba9ceddd 100644 Binary files a/doc/binary_c2.pdf and b/doc/binary_c2.pdf differ diff --git a/src/binary_c_parameters.h b/src/binary_c_parameters.h index 22086b5e242b50fd11bcb33f5c52e475b28ac0c9..bc90acea45daa83703ec733c62203b26aed30de2 100644 --- a/src/binary_c_parameters.h +++ b/src/binary_c_parameters.h @@ -1267,7 +1267,7 @@ /************************************************************ * 2017 treatment of circumstellar and circumbinary discs ************************************************************/ -#define DISCS +//#define DISCS #ifdef DISCS @@ -1355,7 +1355,7 @@ /* * Logging for individual systems with discs */ -#define DISC_LOG +//#define DISC_LOG //#define DISC_LOG_2D diff --git a/src/disc/disc_calc_disc_structure.c b/src/disc/disc_calc_disc_structure.c index 7d366ae235030394699b436bda3adce632a58a9c..76a7622445289e168f80742b6602155def6bfe25 100644 --- a/src/disc/disc_calc_disc_structure.c +++ b/src/disc/disc_calc_disc_structure.c @@ -39,6 +39,11 @@ static int GSL_multiroot(struct stardata_t * stardata, #endif +static Boolean check_local_minimum(struct stardata_t * stardata, + struct disc_t * disc, + struct binary_system_t * binary); + + static int bisection_rooter(struct stardata_t * stardata, struct disc_t * disc, @@ -591,6 +596,14 @@ int disc_calc_disc_structure(struct binary_system_t * binary, Convergence_status(disc->converged)); disc_convergence_status("calc_structure_return",disc,binary); Safe_free(discwas); + + + + if(0 && disc->converged) + { + check_local_minimum(stardata,disc,binary); + } + return ret; } @@ -1505,10 +1518,85 @@ static int bisection_rooter(struct stardata_t * stardata, * Set return values */ *return_failed = failed; + + if(0 && disc->converged) + { + check_local_minimum(stardata,disc,binary); + } + return converged; } +static Boolean check_local_minimum(struct stardata_t * stardata, + struct disc_t * disc, + struct binary_system_t * binary) +{ + /* + * Check if the disc is at a local minimum in parameter space + */ + + /* + * Step size: assume 10 * tolerance, although this + * is a bit rough. + */ + double d = DISC_TOLERANCE * 100.0; + + /* + * Make a copy of the input disc + */ + struct disc_t * testdisc = MALLOC(sizeof(struct disc_t)); + + + /* + * epsilons + */ + +#define Perturb(V,N) \ + double d##V = d * disc->V; \ + double xx##V##low[3],xx##V##mid[3],xx##V##hi[3]; \ + \ + memcpy(testdisc,disc,sizeof(struct disc_t)); \ + testdisc->V = disc->V - d##V; \ + disc_trisector2(testdisc,binary,xx##V##low); \ + PRINTF("LOCAL %s LOW xx##V %g %g %g\n",Stringify(V),xx##V##low[0],xx##V##low[1],xx##V##low[2]); \ + \ + memcpy(testdisc,disc,sizeof(struct disc_t)); \ + testdisc->V = disc->V; \ + disc_trisector2(testdisc,binary,xx##V##mid); \ + PRINTF("LOCAL %s MID xx##V %g %g %g\n",Stringify(V),xx##V##mid[0],xx##V##mid[1],xx##V##mid[2]); \ + \ + memcpy(testdisc,disc,sizeof(struct disc_t)); \ + testdisc->V = disc->V + d##V; \ + disc_trisector2(testdisc,binary,xx##V##hi); \ + PRINTF("LOCAL %s HIGH xx##V %g %g %g\n", \ + Stringify(V), \ + xx##V##hi[0], \ + xx##V##hi[1], \ + xx##V##hi[2]); \ + \ + if(fabs(xx##V##low[N]) > fabs(xx##V##mid[N]) && \ + fabs(xx##V##hi[N]) > fabs(xx##V##mid[N])) \ + { \ + PRINTF("LOCALTEST OK\n"); \ + } \ + else \ + { \ + PRINTF("LOCALTEST FAIL\n"); \ + if(0)Exit_binary_c(2,"pants"); \ + } + + /* + * Perturb variables + */ + + Perturb(Tvisc0,0); + Perturb(Rin,1); + Perturb(Rout,2); + + Safe_free(testdisc); + return TRUE; +} #endif // DISCS && DISCS_JERMYN diff --git a/src/disc/disc_prototypes.h b/src/disc/disc_prototypes.h index 9d639e6597bc6d918a0e28aa9245474bac6ef49c..926349c5371ac9e919d86526926aae83997409f4 100644 --- a/src/disc/disc_prototypes.h +++ b/src/disc/disc_prototypes.h @@ -257,6 +257,9 @@ void disc_trisector(const double Tvisc0, const double Rout, double *xx, void * p); +void disc_trisector2(struct disc_t * disc, + struct binary_system_t * binary, + double *xx); void disc_convergence_status(char * s, struct disc_t * disc, diff --git a/src/disc/disc_trisector.c b/src/disc/disc_trisector.c index 61b93fca1643023bf08a056ad934f077cc31142f..6d23616dd2564b6d11eb755aee4ec2b88696f1c2 100644 --- a/src/disc/disc_trisector.c +++ b/src/disc/disc_trisector.c @@ -19,6 +19,8 @@ * is converged. */ + + void disc_trisector(const double Tvisc0, const double Rin, const double Rout, @@ -29,6 +31,11 @@ void disc_trisector(const double Tvisc0, struct disc_t * disc = va_arg(args, struct disc_t *); struct binary_system_t * binary = va_arg(args,struct binary_system_t * ); va_end(args); + + disc->Tvisc0 = Tvisc0; + disc->Rin = Rin; + disc->Rout = Rout; + Discdebug(2, "Trisect Rin=%g Rout=%g Tvisc0=%g (disc=%p binary=%p)\n", Rin, @@ -36,10 +43,21 @@ void disc_trisector(const double Tvisc0, Tvisc0, disc, binary); - - disc->Tvisc0 = Tvisc0; - disc->Rin = Rin; - disc->Rout = Rout; + + disc_trisector2(disc, + binary, + xx); +} + + + +void disc_trisector2(struct disc_t * disc, + struct binary_system_t * binary, + double *xx) +{ + /* + * + */ int status = disc_build_disc_zones(disc,binary); @@ -66,7 +84,7 @@ void disc_trisector(const double Tvisc0, ); xx[0] = M/disc->M - 1.0; xx[1] = J/disc->J - 1.0; - xx[2] = F/disc->F - 1.0; + xx[2] = fabs(F/disc->F) - 1.0; } else { @@ -76,5 +94,4 @@ void disc_trisector(const double Tvisc0, } } - #endif // DISCS diff --git a/zipup b/zipup index 43df4d55ee3c7970087505bd0997324e7afbad6d..963404574177ba23df572a0d00bda91058b6b550 100755 --- a/zipup +++ b/zipup @@ -26,6 +26,6 @@ echo "Making zip file" ZIPFILE="binary_c-$VERSION.zip" echo "Big zip file : $ZIPFILE" -zip -u -9 -r -y $ZIPFILE src/*.c src/*/*.c src/*.sh src/*/*.sh src/*.h src/*/*.h src/*/*.plt src/gnuplot/* src/Makefile make Makefile ./configure tbse doc/* zipup TODO README LICENCE CHANGES src/perl/* networks apitest/*.c apitest/*.sh apitest/*.f90 apitest/*.pl apitest/*.so apitest/Make* apitest/README -x \*svn\* -x \*.o +zip -u -9 -r -y $ZIPFILE data_object_list.sh double2bin.c test.c src/*.c src/*/*.c src/*.sh src/*/*.sh src/*.h src/*/*.h src/*/*.plt src/gnuplot/* src/Makefile make Makefile ./configure tbse doc/* zipup TODO README LICENCE CHANGES src/perl/* networks apitest/*.c apitest/*.sh apitest/*.f90 apitest/*.pl apitest/*.so apitest/Make* apitest/README -x \*svn\* -x \*.o