diff --git a/CHANGES b/CHANGES index e82130ebf814437c3c06b5d73eb21a0b851b2118..f7c27ed67c5edefa306f48cc9c23d3321b6d0f47 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ Updates to the meson build to make it more efficient. Change how reset_timeout works so it doesn't require LINUX, rather it requires __HAVE_SETITIMER__ (which is checked for by Meson). +The binary_grid (v1) perl module has been completely deprecated in favour of binary_grid2. + 14/11/2019 V2.1.4 What a difference a week makes. 2.1.4 brings some (minor) bug fixes, but diff --git a/src/perl/modules_targz/Binning-0.03.tar.gz b/src/perl/modules_targz/Binning-0.03.tar.gz index c3a6079a6621a5796d8b9c8b6951e690e99ef7da..9bf271c64dd56fbed247e6eff39a40b708624fbe 100644 Binary files a/src/perl/modules_targz/Binning-0.03.tar.gz and b/src/perl/modules_targz/Binning-0.03.tar.gz differ diff --git a/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz b/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz index deba612bec0ab2d24ad235519413b8c17a0c258f..0c1fcbf12a54289dbae7397bab0b250763b31ee8 100644 Binary files a/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz and b/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz differ diff --git a/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz b/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz index bb04e9e9798eb44c6ced0eff49ccbb085753e5c8..a1f44a2e279da87cc5a1a66afa791f9bbf346098 100644 Binary files a/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz and b/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz differ diff --git a/src/perl/modules_targz/Histogram-0.01.tar.gz b/src/perl/modules_targz/Histogram-0.01.tar.gz index dd83e23ec4855653e62f32cc7bda637ff2ec2d43..5ac40c114d2963af805a84986e4a4061fab93044 100644 Binary files a/src/perl/modules_targz/Histogram-0.01.tar.gz and b/src/perl/modules_targz/Histogram-0.01.tar.gz differ diff --git a/src/perl/modules_targz/IMF-0.05.tar.gz b/src/perl/modules_targz/IMF-0.05.tar.gz index 836e1b16c9bb213fff5c8e82a76ba2d2e89bc2bc..5cf4fa94e270ed01b2d222acffeaafa234e89b0b 100644 Binary files a/src/perl/modules_targz/IMF-0.05.tar.gz and b/src/perl/modules_targz/IMF-0.05.tar.gz differ diff --git a/src/perl/modules_targz/Maths_Double-0.01.tar.gz b/src/perl/modules_targz/Maths_Double-0.01.tar.gz index ee1caf071d840a60c34c68b2a20efc36257b42e7..0ab8311175fef34d7081de709e13a0c898ba9bce 100644 Binary files a/src/perl/modules_targz/Maths_Double-0.01.tar.gz and b/src/perl/modules_targz/Maths_Double-0.01.tar.gz differ diff --git a/src/perl/modules_targz/RobInterpolation-0.04.tar.gz b/src/perl/modules_targz/RobInterpolation-0.04.tar.gz index ab798ecc41fbb910d803c248c30f4bfda77a8ca4..a5bda8501ad1b3a80562b997dcb38fa614bc2fd7 100644 Binary files a/src/perl/modules_targz/RobInterpolation-0.04.tar.gz and b/src/perl/modules_targz/RobInterpolation-0.04.tar.gz differ diff --git a/src/perl/modules_targz/binary_grid-v2.1.5.tar.gz b/src/perl/modules_targz/binary_grid-v2.1.5.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..4ec41db926194b72f145e36c6cf449c133b01325 Binary files /dev/null and b/src/perl/modules_targz/binary_grid-v2.1.5.tar.gz differ diff --git a/src/perl/modules_targz/binary_stars-0.05.tar.gz b/src/perl/modules_targz/binary_stars-0.05.tar.gz index 0d986a089623a5ad333fce2dd5964394d8a593bd..5f592eedd09de5d5cdfab5e5a8787629213385e2 100644 Binary files a/src/perl/modules_targz/binary_stars-0.05.tar.gz and b/src/perl/modules_targz/binary_stars-0.05.tar.gz differ diff --git a/src/perl/modules_targz/cosmology-0.01.tar.gz b/src/perl/modules_targz/cosmology-0.01.tar.gz index 3c24df7cfa726eac282e6cc4a6612513003792c0..5503112ba3bfd37e7ccd77ebc5a4500ca00dee06 100644 Binary files a/src/perl/modules_targz/cosmology-0.01.tar.gz and b/src/perl/modules_targz/cosmology-0.01.tar.gz differ diff --git a/src/perl/modules_targz/distribution_functions-0.05.tar.gz b/src/perl/modules_targz/distribution_functions-0.05.tar.gz index 70d96189ea12c796cd132cc6de76f75dff9a6cfd..c365b8a02d26ad0323f4aea62fa2da690920ad03 100644 Binary files a/src/perl/modules_targz/distribution_functions-0.05.tar.gz and b/src/perl/modules_targz/distribution_functions-0.05.tar.gz differ diff --git a/src/perl/modules_targz/rob_misc-0.16.tar.gz b/src/perl/modules_targz/rob_misc-0.16.tar.gz index 0397c1d075d10bf6023fd3e8697bd4c66cf4c78f..7e61a8e4554539a6ab2b327035f4211615a2e089 100644 Binary files a/src/perl/modules_targz/rob_misc-0.16.tar.gz and b/src/perl/modules_targz/rob_misc-0.16.tar.gz differ diff --git a/src/perl/modules_targz/robqueue-0.05.tar.gz b/src/perl/modules_targz/robqueue-0.05.tar.gz index b511886446dde8031dcdfc0791b43a5cb5faff23..883fecc0bc04a351b2fc1d08e64c022a92253f64 100644 Binary files a/src/perl/modules_targz/robqueue-0.05.tar.gz and b/src/perl/modules_targz/robqueue-0.05.tar.gz differ diff --git a/src/perl/modules_targz/spacing_functions-0.02.tar.gz b/src/perl/modules_targz/spacing_functions-0.02.tar.gz index 6e5140060b83a512b58ccabf188ec0f705b0f104..5d63fb6f2b18565875b222bdce1518b6db230dfe 100644 Binary files a/src/perl/modules_targz/spacing_functions-0.02.tar.gz and b/src/perl/modules_targz/spacing_functions-0.02.tar.gz differ diff --git a/src/perl/scripts2/template.pl b/src/perl/scripts2/template.pl index 660a74a02f4f27b282807e9960ff03d0e95cd80e..b3f98f7cfa06bcf90063d2bbd258f627e9879fe1 100755 --- a/src/perl/scripts2/template.pl +++ b/src/perl/scripts2/template.pl @@ -4,6 +4,7 @@ use 5.16.0; # recommended use binary_grid2; # required use binary_grid::C; # backend : C or Perl use rob_misc qw/ncpus/; +use Maths_Double; ############################################################ # @@ -20,13 +21,13 @@ use rob_misc qw/ncpus/; my $nthreads = rob_misc::ncpus(); ############################################################ -# Binary_c should output data that we can understand. There -# are two ways to do this: +# Binary_c should output data that we can understand here. +# There are two ways to do this: # -# 1) Put output statements, using PRINTF, in binary_c's +# 1) Put output statements, using Printf, in binary_c's # log_every_timestep() function. This requires a rebuild # of libbinary_c.so and a reinstall of the binary_grid module -# every time you change the PRINTF statement. +# every time you change the Printf statement. # # # 2) Put a list of hashes in the C_auto_logging grid option @@ -51,10 +52,10 @@ my $nthreads = rob_misc::ncpus(); # reinstall of binary_grid. # # -# 3) Put output statements, using PRINTF, into the C_logging_code +# 3) Put output statements, using Printf, into the C_logging_code # grid option # -# $population->set( C_logging_code => ' PRINTF("...\n"); '); +# $population->set( C_logging_code => ' Printf("...\n"); '); # # You have access to the stardata variable, so you can # output everything that is available to log_every_timestep(); @@ -67,7 +68,7 @@ my $nthreads = rob_misc::ncpus(); my $population = binary_grid2->new( # options can be given now ... metallicity => 0.02, # mass fraction of "metals" - max_evolution_time => 0.01,#15000, # Myr + max_evolution_time => 0.1,#15000, # Myr nthreads=>$nthreads, # number of threads ); @@ -89,21 +90,16 @@ $population->set( 'model.dt' ] }, - # C_logging_code => - # 'PRINTF("stardata = %p\n",stardata);' - # , - individual_novae=>0, ## or enter more complicated code yourself: # # C_logging_code => ' -# PRINTF("MY_STELLAR_DATA %g %g %g %g\n", -# stardata->model.time, -# stardata->star[0].mass, -# stardata->model.probability, -# stardata->model.dt); - # ' - +# Printf("MY_STELLAR_DATA %g %g %g %g\n", +# stardata->model.time, +# stardata->star[0].mass, +# stardata->model.probability, +# stardata->model.dt); +# ', ); @@ -125,7 +121,7 @@ if($duplicity == 0) { # make a grid of $nstars single binary stars, log-spaced, # with masses between $mmin and $mmax - my $nstars = 10000; + my $nstars = 1000; my $mmin = 0.1; my $mmax = 80.0; $population->add_grid_variable( @@ -136,17 +132,18 @@ if($duplicity == 0) 'spacingfunc'=>"const(log($mmin),log($mmax),$nstars)", 'precode' =>'$m1=exp($lnm1);', 'probdist' =>'Kroupa2001($m1)*$m1', - 'method' => ("@ARGV"=~/mc/ ? 'monte carlo' : 'grid'), - 'monte carlo lookup resolution' => 1000, + 'method' =>'grid', + 'gridtype' => 'centred', ); } elsif($duplicity == 1) { # make a population of binary stars + my $nres = 20; my $resolution = { - m1 => 10, - q => 10, - P => 10 + m1 => $nres, + q => $nres, + P => $nres, }; my $mmin = 0.1; my $mmax = 80.0; @@ -161,6 +158,8 @@ elsif($duplicity == 1) 'spacingfunc'=>"const(log($mmin),log($mmax),$resolution->{m1})", 'precode' =>'$m1=exp($lnm1);', 'probdist' =>'Kroupa2001($m1)*$m1', + 'method' =>'grid', + 'gridtype' =>'centred', ); # q=M1/M2 distribution flat in q between 0.1/M1 and 1.0 $population->add_grid_variable @@ -169,13 +168,16 @@ elsif($duplicity == 1) 'name' =>'q', 'longname' =>'Mass ratio', 'range' =>['0.1/$m1',1.0], - 'resolution'=>$resolution->{q}, + 'resolution'=>$resolution->{q}, 'spacingfunc'=>"const(0.1/\$m1,1.0,$resolution->{q})", - 'probdist' =>"flatsections\(\$q,\[ -\{min=>0.1/\$m1,max=>0.8,height=>1.0\}, -\{min=>0.8,max=>1.0,height=>1.0\}, -\]\)", - precode =>'$m2=$q*$m1;', + 'precode' =>'$m2=$q*$m1;', + 'probdist' =>' +flatsections($q,[ + {min=>0.1/$m1,max=>0.8,height=>1.0}, + {min=>0.8,max=>1.0,height=>1.0}, + ])', + 'method' => 'grid', + 'gridtype' => 'centred', ); # orbital period Duquennoy and Mayor 1991 distribution my $Prange = [-2.0,12.0]; @@ -186,11 +188,14 @@ elsif($duplicity == 1) 'range' =>$Prange, 'resolution' =>$resolution->{P}, 'spacingfunc'=>"const($Prange->[0],$Prange->[1],$resolution->{P})", - 'precode'=>"\$per = 10.0 ** \$logper; -my \$eccentricity = 0.0; -\$sep=calc_sep_from_period(\$m1,\$m2,\$per) if(defined \$m1 && defined \$m2); -", + 'precode'=>' +$per = 10.0 ** $logper; +my $eccentricity = 0.0; +$sep = calc_sep_from_period($m1,$m2,$per) if(defined $m1 && defined $m2); +', 'probdist'=>"gaussian(\$logper,4.8,2.3,$Prange->[0],$Prange->[1])", + 'method' =>'grid', + 'gridtype' => 'centred', ); } else @@ -291,6 +296,22 @@ sub parse_data { my ($population, $results) = @_; + my $progenitor = $population->progenitor(); + + # get initial mass and probability for the initial mass function + my $progenitor_initial_mass = + $progenitor->{m1} + + ($duplicity ? $population->progenitor()->{m2} : 0.0); + + my $progenitor_probability = $population->progenitor()->{prob}; + + # bin initial mass + my $binned_initial_mass = $population->rebin($progenitor_initial_mass,1.0); + + # initial mass function + $results->{initial_mass_function}->{$binned_initial_mass} += + $progenitor_probability; + while(1) { # subsequent calls to tbse_line contain @@ -312,6 +333,11 @@ sub parse_data #print "GOT @$la\n"; # matched MY_STELLAR_DATA header + # + # get time, mass, probability etc. as specified above + # + # (note that $probability is possibly not the same as + # the progenitor's probability!) my $time = $la->[0]; my $mass = $la->[1]; my $probability = $la->[2]; @@ -320,12 +346,6 @@ sub parse_data # bin mass to nearest 1.0 Msun $mass = $population->rebin($mass, 1.0); - # add up the initial mass function - if($time == 0.0) - { - $results->{initial_mass_function}->{$mass} += $probability; - } - # add up the mass distribution $results->{mass_distribution}->{$mass} += $probability * $timestep; } @@ -342,6 +362,14 @@ sub output # the results that were added up in parse_data() my $results = $population->results; + if(0) + { + # show results hash in full + print "############################################################\n"; + print Data::Dumper::Dumper($results); + print "############################################################\n"; + } + # output the initial mass function foreach my $mass (sort {$a<=>$b} keys %{$results->{initial_mass_function}}) {