Skip to content

Commit

Permalink
Merge branch 'master' into APIUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
parikshitbajpai committed Jun 29, 2023
2 parents 9ac6e78 + 3ca57bf commit b3827ef
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/Thermochimica-cxx.C
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ namespace Thermochimica
}

// utilitiy functions for consistency check / database record

std::size_t getNumberElementsDatabase()
{
int n_elements;
Expand Down Expand Up @@ -169,6 +170,7 @@ namespace Thermochimica
std::vector<std::string> getPhaseNamesSystem()
{
auto [n_soln_phases, n_cond_phases] = getNumberPhasesSystem();

auto n_phases = n_soln_phases + n_cond_phases;

std::vector<std::string> phase_names(n_phases);
Expand All @@ -186,6 +188,7 @@ namespace Thermochimica
std::vector<int> n_sp(n_soln_phases);
std::vector<std::size_t> n_species(n_soln_phases);
TCAPI_getNumberSpeciesSystem(n_sp.data());

for (std::size_t i = 0; i < n_soln_phases; ++i)
n_species[i] = (std::size_t)n_sp[i];

Expand All @@ -205,10 +208,12 @@ namespace Thermochimica
std::vector<std::vector<std::string>> getSpeciesSystem()
{
auto [n_soln_phases, n_cond_phases] = getNumberPhasesSystem();

(void)n_cond_phases;
std::vector<std::vector<std::string>> species(n_soln_phases);

for (std::size_t i = 0; i < n_soln_phases; ++i)

species[i] = getSpeciesInPhase(i);

return species;
Expand All @@ -231,10 +236,12 @@ namespace Thermochimica
else
n_species_phase = phase_index == 0 ? n_species[phase_index] : n_species[phase_index] - n_species[phase_index - 1];


std::vector<std::string> species(n_species_phase);

for (std::size_t i = 0; i < n_species_phase; ++i)
{

if (is_mqm)
{
index = i + 1;
Expand Down
1 change: 1 addition & 0 deletions src/Thermochimica-cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Thermochimica
void resetThermoAll();

// utilitiy functions for consistency check / database record

std::size_t getNumberElementsDatabase();
std::vector<std::string> getElementsDatabase();
std::string getElementAtIndex(int element_index);
Expand Down
1 change: 1 addition & 0 deletions src/Thermochimica.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern "C"
void TCAPI_getNumberPhasesSystem(int *, int *);
char *TCAPI_getPhaseNameAtIndex(int *, int *);
void TCAPI_getNumberSpeciesSystem(int *);

char *TCAPI_getSpeciesAtIndex(int *, int *);

void TCAPI_resetInfoThermo();
Expand Down
2 changes: 1 addition & 1 deletion src/api/CouplingUtilities.f90
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ subroutine SetElementMass(iAtom, dMass)

end subroutine SetElementMass


subroutine GetNumberPhasesSystem(iNumSolnPhases, iNumConPhases)

! USE ModuleParseCS, ONLY: nSpeciesCS, nSpeciesPhaseCS, nSolnPhasesSysCS
USE ModuleThermo, ONLY: nSolnPhasesSys, nConPhasesSys

implicit none
Expand Down
4 changes: 4 additions & 0 deletions src/api/CouplingUtilitiesISO_C.f90
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ subroutine ResetThermoAllISO() &

end subroutine ResetThermoAllISO


subroutine GetNumberPhasesSystemISO(iSolnPhases, iConPhases) &
bind(C, name="TCAPI_getNumberPhasesSystem")

Expand All @@ -305,6 +306,7 @@ function GetPhaseNameAtIndexISO(phase_index, phase_name_len) &
bind(C, name='TCAPI_getPhaseNameAtIndex')

USE, INTRINSIC :: ISO_C_BINDING

USE ModuleThermo

implicit none
Expand Down Expand Up @@ -341,6 +343,7 @@ subroutine GetNumberSpeciesSystemISO(nSpeciesDB) &

end subroutine GetNumberSpeciesSystemISO


function GetSpeciesAtIndexISO(index, len) &
bind(C, name='TCAPI_getSpeciesAtIndex')

Expand All @@ -356,6 +359,7 @@ function GetSpeciesAtIndexISO(index, len) &
GetSpeciesAtIndexISO = c_loc(cSpeciesName(index))
len = len_trim(cSpeciesName(index))


return

end function GetSpeciesAtIndexISO
Expand Down
12 changes: 9 additions & 3 deletions src/gem/Subminimization.f90
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ subroutine SubMinLineSearch(iSolnPhaseIndex)
implicit none

integer :: i, j, k, iSolnPhaseIndex
real(8) :: dStepLength, dTemp, dMaxChange
real(8) :: dStepLength, dTemp, dMaxChange, dChange

! Initialize variables:
dStepLength = 1D0
Expand Down Expand Up @@ -575,9 +575,15 @@ subroutine SubMinLineSearch(iSolnPhaseIndex)
! Absolute species index:
i = iFirst + j - 1
! Apply step length:
dMolFraction(i) = dMolFraction(i) + dStepLength * dRHS(j)
dChange = dStepLength * dRHS(j)
if (dMolFraction(i) + dChange > 1D0) then
dChange = 1D0 - dMolFraction(i)
end if
dMolFraction(i) = dMolFraction(i) + dChange
! Store maximum change to the mole fraction:
dTemp = DMAX1(dTemp, DABS(dRHS(j)))
if (dChange > dTemp) then
dTemp = dChange
end if
end do

! Iterate to satisfy Wolfe conditions:
Expand Down
8 changes: 1 addition & 7 deletions src/postprocess/PostProcessThermo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ subroutine PostProcessThermo

! Multiply the number of moles of all phases by the normalizing constant:
dNormalizeInput = 1D0 / dNormalizeInput
! print *, "========================= Moles Element ========================= "
! print *, dMolesElement
! print *, "========================= Normalize Input ========================= "
! print *, dNormalizeInput
! print *, "========================= Mass Scale ========================= "
! print *, dMassScale
! print *, " "

dMolesPhase = dMolesPhase * dNormalizeInput * dMassScale
dMolesElement = dMolesElement * dNormalizeInput * dMassScale
dMolesSpecies = dMolesSpecies * dNormalizeInput * dMassScale
Expand Down

0 comments on commit b3827ef

Please sign in to comment.