Skip to content

Commit

Permalink
Merge pull request #5 from srebughini/api
Browse files Browse the repository at this point in the history
C++ API and Elapsed time
  • Loading branch information
srebughini authored Jan 30, 2021
2 parents 35e1fd2 + 015dd25 commit 214f5b3
Show file tree
Hide file tree
Showing 24 changed files with 17,417 additions and 75 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Asali
__*
API/C/example
API/C/database-generator
API/Cpp/example
API/Cpp/database-generator
API/Fortran/example
API/Fortran/database-generator
API/Fortran/*.mod
API/elapsedTimeComparison/*.mod
API/elapsedTimeComparison/asali-*
27 changes: 5 additions & 22 deletions API/C/Asali.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void set_temperature(Asali* asali_, double T)
asali_->hmole_mix_updated_ = false;
asali_->hmass_mix_updated_ = false;
asali_->smole_mix_updated_ = false;
asali_->smass_mix_updated_ = false;
}
}

Expand All @@ -90,7 +89,6 @@ void set_pressure(Asali* asali_, double P)
asali_->hmole_mix_updated_ = false;
asali_->hmass_mix_updated_ = false;
asali_->smole_mix_updated_ = false;
asali_->smass_mix_updated_ = false;
}
}

Expand All @@ -116,7 +114,6 @@ void set_number_of_species(Asali* asali_,int NC)
asali_->hmole_mix_updated_ = false;
asali_->hmass_mix_updated_ = false;
asali_->smole_mix_updated_ = false;
asali_->smass_mix_updated_ = false;
resize(asali_,NC);
}
}
Expand Down Expand Up @@ -161,7 +158,6 @@ void set_species_names(Asali* asali_,AsaliVector names)
asali_->hmole_mix_updated_ = false;
asali_->hmass_mix_updated_ = false;
asali_->smole_mix_updated_ = false;
asali_->smass_mix_updated_ = false;
}
else
{
Expand Down Expand Up @@ -203,7 +199,6 @@ void set_mass_fraction(Asali* asali_,AsaliVector y)
asali_->hmole_mix_updated_ = false;
asali_->hmass_mix_updated_ = false;
asali_->smole_mix_updated_ = false;
asali_->smass_mix_updated_ = false;
}
else
{
Expand Down Expand Up @@ -244,7 +239,6 @@ void set_mole_fraction(Asali* asali_,AsaliVector x)
asali_->hmole_mix_updated_ = false;
asali_->hmass_mix_updated_ = false;
asali_->smole_mix_updated_ = false;
asali_->smass_mix_updated_ = false;
}
else
{
Expand Down Expand Up @@ -505,7 +499,6 @@ void species_h_(Asali* asali_)
}
}


void species_s_(Asali* asali_)
{
if ( !asali_->s_updated_ )
Expand Down Expand Up @@ -533,14 +526,15 @@ void species_s_(Asali* asali_)
+ asali_->thermo_[idx].high[6];
}

set_vector_element_from_double(&asali_->s_mole_,i,s*8314.); //J/kmol/K
set_vector_element_from_double(&asali_->s_mass_,i,s*8314/get_vector_element_as_double(&asali_->MW_,i)); //J/kg/K
s = 8314.*(s - log(asali_->P_*get_vector_element_as_double(&asali_->x_,i)/1.0e05));

set_vector_element_from_double(&asali_->s_mole_,i,s); //J/kmol/K
set_vector_element_from_double(&asali_->s_mass_,i,s/get_vector_element_as_double(&asali_->MW_,i)); //J/kg/K
}
asali_->s_updated_ = true;
}
}


double get_mixture_thermal_conductivity(Asali* asali_) //[W/m/K]
{
if ( !asali_->cond_mix_updated_ )
Expand Down Expand Up @@ -720,17 +714,7 @@ double get_mixture_molar_entropy(Asali* asali_)

double get_mixture_mass_entropy(Asali* asali_)
{
if ( !asali_->smass_mix_updated_ )
{
species_s_(asali_);
asali_->smass_mix_ = 0.;
for (int i=0;i<asali_->NC_;i++)
{
asali_->smass_mix_ = asali_->smass_mix_ + get_vector_element_as_double(&asali_->y_,i)*get_vector_element_as_double(&asali_->s_mass_,i);
}
asali_->smass_mix_updated_ = true;
}

asali_->smass_mix_ = get_mixture_molar_entropy(asali_)/asali_->MWmix_;
return asali_->smass_mix_;
}

Expand Down Expand Up @@ -789,7 +773,6 @@ void initialize(Asali* asali_)
asali_->hmole_mix_updated_ = false;
asali_->hmass_mix_updated_ = false;
asali_->smole_mix_updated_ = false;
asali_->smass_mix_updated_ = false;

asali_->pi_ = 3.14159265358979323846;

Expand Down
1 change: 0 additions & 1 deletion API/C/Asali.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ typedef struct
bool hmole_mix_updated_;
bool hmass_mix_updated_;
bool smole_mix_updated_;
bool smass_mix_updated_;

AsaliVector name_;
AsaliVector index_;
Expand Down
4 changes: 0 additions & 4 deletions API/C/compile.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
echo "Database"
rm -f database-generator
gcc database-generator.c -o database-generator
./database-generator

echo "Example"
rm -f example
gcc example.c AsaliVector.c AsaliMatrix.c Asali.c -lm -o example
./example
20 changes: 20 additions & 0 deletions API/C/thermo.H
Original file line number Diff line number Diff line change
Expand Up @@ -9178,6 +9178,26 @@ void thermo_update(Asali* asali_)
asali_->thermo_[435].low[5] = 6.0020937500e+04;
asali_->thermo_[435].low[6] = 2.9624124527e+01;

asali_->thermo_[436].name = (char*) malloc(7 * sizeof(char));
strcpy(asali_->thermo_[436].name,"BENZYNE");

asali_->thermo_[436].high = (float*) malloc(7 * sizeof(float));
asali_->thermo_[436].high[0] = 1.0946581841e+01;
asali_->thermo_[436].high[1] = 1.5037324280e-02;
asali_->thermo_[436].high[2] = -5.2784494073e-06;
asali_->thermo_[436].high[3] = 8.1460760359e-10;
asali_->thermo_[436].high[4] = -4.4907335500e-14;
asali_->thermo_[436].high[5] = 5.0330140625e+04;
asali_->thermo_[436].high[6] = -3.5378292084e+01;

asali_->thermo_[436].low = (float*) malloc(7 * sizeof(float));
asali_->thermo_[436].low[0] = -3.7379617691e+00;
asali_->thermo_[436].low[1] = 5.6993164122e-02;
asali_->thermo_[436].low[2] = -5.0231134082e-05;
asali_->thermo_[436].low[3] = 2.2220648432e-08;
asali_->thermo_[436].low[4] = -3.8674146351e-12;
asali_->thermo_[436].low[5] = 5.4441812500e+04;
asali_->thermo_[436].low[6] = 4.0407081604e+01;

asali_->thermo_[437].name = (char*) malloc(8 * sizeof(char));
strcpy(asali_->thermo_[437].name,"NC10MOOH");
Expand Down
Loading

0 comments on commit 214f5b3

Please sign in to comment.