Skip to content

Commit

Permalink
WIP refactor TC API
Browse files Browse the repository at this point in the history
  • Loading branch information
parikshitbajpai committed Jun 8, 2023
1 parent 62fb106 commit 04c2956
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 24 deletions.
20 changes: 18 additions & 2 deletions src/Thermochimica-cxx.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ namespace Thermochimica
TCAPI_thermochimica();
}

void setThermoFilename(const std::string &filename)
void thermochimicaSolver()
{
TCAPI_thermochimicaSolver();
}

void

void
setThermoFilename(const std::string &filename)
{
TCAPI_setThermoFilename(filename.c_str(), filename.length());
}
Expand Down Expand Up @@ -75,7 +83,7 @@ namespace Thermochimica

void parseThermoFile()
{
TCAPI_sSParseCSDataFile();
TCAPI_parseCSDataFile();
}

void setPrintResultsMode(int mode)
Expand Down Expand Up @@ -225,6 +233,14 @@ namespace Thermochimica
return potential;
}

// std::pair<double, int> getElementPotential(const int elementID)
// {
// double potential;
// int info;
// TCAPI_getElementPotential(&elementID, &potential, &info);
// return {potential, info};
// }

double getElementFraction(int atomicNumber)
{
double fraction;
Expand Down
1 change: 1 addition & 0 deletions src/Thermochimica-cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Thermochimica
{

void thermochimica();
void thermochimicaSolver();
void setThermoFilename(const std::string &filename);
void setUnitTemperature(const std::string &tunit);
void setUnitPressure(const std::string &punit);
Expand Down
51 changes: 31 additions & 20 deletions src/Thermochimica.f90
Original file line number Diff line number Diff line change
Expand Up @@ -416,31 +416,12 @@
!
!-------------------------------------------------------------------------------


subroutine Thermochimica

subroutine ThermochimicaSolver
USE ModuleThermoIO
USE ModuleThermo

implicit none

! Check the input variables:
if (INFOThermo == 0) call CheckThermoInput

! Initialize Thermochimica:
if (INFOThermo == 0) call InitThermo

! Check that the system in the data-file is consistent with the input data
! variables:
if (INFOThermo == 0) call CheckSystem

! Compute thermodynamic data using the parameters from the specified
! ChemSage data-file:
if (INFOThermo == 0) call CompThermoData

! Check the thermodynamic database to ensure that it is appropriate:
if (INFOThermo == 0) call CheckThermoData

! Check is load is requested and data available:
lReinitLoaded = .FALSE.
if ((INFOThermo == 0) .AND. lReinitRequested .AND. lReinitAvailable) call LoadReinitData
Expand Down Expand Up @@ -474,4 +455,34 @@ subroutine Thermochimica

return

end subroutine ThermochimicaSolver

subroutine Thermochimica

USE ModuleThermoIO
USE ModuleThermo

implicit none

! Check the input variables:
if (INFOThermo == 0) call CheckThermoInput

! Initialize Thermochimica:
if (INFOThermo == 0) call InitThermo

! Check that the system in the data-file is consistent with the input data
! variables:
if (INFOThermo == 0) call CheckSystem

! Compute thermodynamic data using the parameters from the specified
! ChemSage data-file:
if (INFOThermo == 0) call CompThermoData

! Check the thermodynamic database to ensure that it is appropriate:
if (INFOThermo == 0) call CheckThermoData

call ThermochimicaSolver

return

end subroutine Thermochimica
3 changes: 2 additions & 1 deletion src/Thermochimica.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ extern "C"
void TCAPI_setTemperaturePressure(double *, double *);
void TCAPI_checkInfoThermo(int *);

void TCAPI_sSParseCSDataFile();
void TCAPI_parseCSDataFile();
void TCAPI_thermochimica();
void TCAPI_thermochimicaSolver();

void TCAPI_solPhaseParse(int *, double *);

Expand Down
15 changes: 14 additions & 1 deletion src/api/CouplingUtilitiesISO_C.f90
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ subroutine SolPhaseParseISO(iElem, dMolSum) &
end subroutine SolPhaseParseISO

subroutine SSParseCSDataFileISO() &
bind(C, name="TCAPI_sSParseCSDataFile")
bind(C, name="TCAPI_parseCSDataFile")

USE,INTRINSIC :: ISO_C_BINDING

Expand All @@ -436,6 +436,19 @@ subroutine ThermochimicaISO() &

end subroutine ThermochimicaISO

subroutine ThermochimicaSolver() &
bind(C, name="TCAPI_thermochimicaSolver")

USE,INTRINSIC :: ISO_C_BINDING

implicit none

call ThermochimicaSolver()

return

end subroutine ThermochimicaSolver

subroutine getMolFractionISO(i, value, ierr) &
bind(C, name="TCAPI_getMolFraction")

Expand Down

0 comments on commit 04c2956

Please sign in to comment.