diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 6729e010ca..fd432f82a5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -6745,6 +6745,44 @@ jobs: ./test-mass-host-maximum.pl 2>&1 | tee test.log ! grep -q FAIL test.log - run: echo "This job's status is ${{ job.status }}." + Test-Noninstantaneous-Recycling: + runs-on: ubuntu-latest + container: ghcr.io/galacticusorg/buildenv:latest + needs: Build-Executable-Linux + steps: + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server." + - run: echo "The name of the branch is ${{ github.ref }} and the repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - name: Check out repository datasets + uses: actions/checkout@v4 + with: + repository: galacticusorg/datasets + path: datasets + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." + - name: "Set environmental variables" + run: | + echo "GALACTICUS_EXEC_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "GALACTICUS_DATA_PATH=$GITHUB_WORKSPACE/datasets" >> $GITHUB_ENV + echo "GALACTICUS_ANALYSIS_PERL_PATH=$GITHUB_WORKSPACE/analysis-perl" >> $GITHUB_ENV + - name: Download executables + uses: actions/download-artifact@v3 + with: + name: galacticus-exec + - name: Create test suite output directory + run: mkdir -p $GALACTICUS_EXEC_PATH/testSuite/outputs + - name: Run test + run: | + cd $GALACTICUS_EXEC_PATH + git config --global --add safe.directory $GALACTICUS_EXEC_PATH + chmod u=wrx ./Galacticus.exe + cd testSuite + chmod u=wrx ./test-noninstantaneous-recycling.pl + set -o pipefail + ./test-noninstantaneous-recycling.pl 2>&1 | tee test.log + ! grep -q FAIL test.log + - run: echo "This job's status is ${{ job.status }}." Test-Satellite-Distance-Minimum: runs-on: ubuntu-latest container: ghcr.io/galacticusorg/buildenv:latest @@ -10405,6 +10443,7 @@ jobs: Test-Inactive-Luminosities, Test-Interoutput-Star-Formation-Rate, Test-Mass-Host-Maximum, + Test-Noninstantaneous-Recycling, Test-Satellite-Distance-Minimum, Test-Tree-Filter-Labels, Test-Constrained-Merger-Trees, diff --git a/source/stellar_astrophysics.tracks.file.F90 b/source/stellar_astrophysics.tracks.file.F90 index 3033da3d7b..6fdbd0bb78 100644 --- a/source/stellar_astrophysics.tracks.file.F90 +++ b/source/stellar_astrophysics.tracks.file.F90 @@ -445,7 +445,7 @@ subroutine fileInterpolationCompute(self,initialMass,metallicity,age,interpolati interpolationFactorsMass(iMetallicity,:)=[0.0d0,1.0d0] massOutOfRange=.true. else - call self%interpolatorMass(iMetallicity)%linearFactors(initialMass,interpolationIndicesMass(iMetallicity,1),interpolationFactorsMass(iMetallicity,:)) + call self%interpolatorMass(jMetallicity)%linearFactors(initialMass,interpolationIndicesMass(iMetallicity,1),interpolationFactorsMass(iMetallicity,:)) interpolationIndicesMass(iMetallicity,2)=interpolationIndicesMass(iMetallicity,1)+1 end if ! Loop over masses. diff --git a/source/stellar_populations.standard.F90 b/source/stellar_populations.standard.F90 index 88b2d21f2d..3f76e76ff7 100644 --- a/source/stellar_populations.standard.F90 +++ b/source/stellar_populations.standard.F90 @@ -190,6 +190,7 @@ function standardConstructorParameters(parameters) result(self) parameters + metalYield 0.0d0 The metal yield to use in the instantaneous stellar evolution approximation. (If not specified it will be computed internally.) @@ -376,7 +377,7 @@ double precision function standardInterpolate(self,abundances_,ageMinimum,ageMax type (integratorCompositeGaussKronrod1D) :: integrator_ integer :: fileFormat , iAge , & & iMetallicity , loopCount , & - & loopCountTotal , i + & loopCountTotal , i double precision :: maximumMass , minimumMass , & & metallicity type (hdf5Object ) :: file , dataset @@ -450,7 +451,7 @@ double precision function standardInterpolate(self,abundances_,ageMinimum,ageMax & *tableAgeCount loopCount = 0 self_ => self - !$omp parallel private (iAge,iMetallicity,progressMessage,minimumMass,maximumMass,integrator_) copyin(self_) + !$omp parallel private (iAge,iMetallicity,progressMessage,minimumMass,maximumMass,integrator_) copyin(self_,indexElement_) allocate(stellarAstrophysics_,mold=self%stellarAstrophysics_) allocate(initialMassFunction_,mold=self%initialMassFunction_) allocate(stellarFeedback_ ,mold=self%stellarFeedback_ ) diff --git a/testSuite/parameters/noninstantaneous_recycling.xml b/testSuite/parameters/noninstantaneous_recycling.xml new file mode 100644 index 0000000000..7539dc3ea6 --- /dev/null +++ b/testSuite/parameters/noninstantaneous_recycling.xml @@ -0,0 +1,474 @@ + + + + + + 2 + 0.9.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testSuite/test-noninstantaneous-recycling.pl b/testSuite/test-noninstantaneous-recycling.pl new file mode 100755 index 0000000000..bdfc5df9eb --- /dev/null +++ b/testSuite/test-noninstantaneous-recycling.pl @@ -0,0 +1,43 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use lib $ENV{'GALACTICUS_EXEC_PATH' }."/perl"; +use lib $ENV{'GALACTICUS_ANALYSIS_PERL_PATH'}."/perl"; +use PDL; +use PDL::NiceSlice; +use PDL::IO::HDF5; +use File::Slurp qw(slurp); +use System::Redirect; + +# Check calculations of noninstantaneous recycling. +# Andrew Benson (23-September-2023) + +# Run the model. +&System::Redirect::tofile("mkdir -p outputs; cd ..; ./Galacticus.exe testSuite/parameters/noninstantaneous_recycling.xml","outputs/noninstantaneous_recycling.log"); +unless ( $? == 0 ) { + print "FAILED: model run:\n"; + system("cat outputs/noninstantaneous_recycling.log"); +} else { + print "SUCCESS: model run\n"; +} +# Read the model data and check for consistency. +my $model = new PDL::IO::HDF5("outputs/noninstantaneous_recycling.hdf5"); +my $outputs = $model ->group('Outputs' ); +my $output = $outputs->group('Output10'); +my $nodeData = $output ->group('nodeData'); +my $data; +$data->{$_} = $nodeData->dataset($_)->get() + foreach ( + "spheroidAbundancesStellarMetals", + "spheroidAbundancesStellarFe" , + "diskAbundancesStellarMetals" , + "diskAbundancesStellarFe" + ); +my $massMetals = $data->{'spheroidAbundancesStellarMetals'}+$data->{'diskAbundancesStellarMetals'}; +my $massFe = $data->{'spheroidAbundancesStellarFe' }+$data->{'diskAbundancesStellarFe' }; +my $nonZero = which($massMetals > 1.0); +my $ratio = +$massFe ->($nonZero) + /$massMetals->($nonZero); +my $status = all($ratio < 0.16) ? "SUCCESS" : "FAILED"; +print $status.": Fe/Z ratio\n"; +exit 0;