Skip to content

Commit

Permalink
Write energies in csv files for 3 phases (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlucf22 authored Dec 6, 2024
1 parent 2b3cb08 commit 43c1611
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 58 deletions.
2 changes: 1 addition & 1 deletion drivers/plotEnergyVsCompositionThreePhase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char* argv[])
boost::optional<pt::ptree&> newton_db;

const int npts = 100;
std::ofstream os("FvsC.dat", std::ios::out);
std::ofstream os("FvsC.csv", std::ios::out);
std::cout << " Compute energies..." << std::endl;

if (Thermo4PFM::checkSublattice(calphad_db))
Expand Down
36 changes: 9 additions & 27 deletions src/CALPHADFreeEnergyFunctionsBinary3Ph2Sl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,39 +468,21 @@ void CALPHADFreeEnergyFunctionsBinary3Ph2Sl::printEnergyVsComposition(
const double temperature, std::ostream& os, const double cmin,
const double cmax, const int npts)
{
const double dc = (cmax - cmin) / (double)(npts - 1);
const double dc = (cmax - cmin) / (double)(npts - 1);
const double phil[3] = { 1., 0., 0. };
const double phia[3] = { 0., 1., 0. };
const double phib[3] = { 0., 0., 1. };

os << "#phi0=1" << std::endl;
os << "c, fL, fA, fB" << std::endl;
for (int i = 0; i < npts; i++)
{
const double conc = i * dc + cmin;

const double phi[3] = { 1., 0., 0. };
double el = fchem(phil, &conc, temperature);
double ea = fchem(phia, &conc, temperature);
double eb = fchem(phib, &conc, temperature);

double e = fchem(phi, &conc, temperature);
os << conc << "\t" << e << std::endl;
}
os << std::endl << std::endl;

os << "#phi1=1" << std::endl;
for (int i = 0; i < npts; i++)
{
const double conc = i * dc + cmin;

const double phi[3] = { 0., 1., 0. };
double e = fchem(phi, &conc, temperature);
os << conc << "\t" << e << std::endl;
}
os << std::endl << std::endl;

os << "#phi2=1" << std::endl;
for (int i = 0; i < npts; i++)
{
const double conc = i * dc + cmin;

const double phi[3] = { 0., 0., 1. };
double e = fchem(phi, &conc, temperature);
os << conc << "\t" << e << std::endl;
os << conc << ", " << el << ", " << ea << ", " << eb << std::endl;
}
}

Expand Down
36 changes: 9 additions & 27 deletions src/CALPHADFreeEnergyFunctionsBinaryThreePhase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,39 +353,21 @@ void CALPHADFreeEnergyFunctionsBinaryThreePhase::printEnergyVsComposition(
const double temperature, std::ostream& os, const double cmin,
const double cmax, const int npts)
{
const double dc = (cmax - cmin) / (double)(npts - 1);
const double dc = (cmax - cmin) / (double)(npts - 1);
const double phil[3] = { 1., 0., 0. };
const double phia[3] = { 0., 1., 0. };
const double phib[3] = { 0., 0., 1. };

os << "#phi0=1" << std::endl;
os << "c, fL, fA, fB" << std::endl;
for (int i = 0; i < npts; i++)
{
const double conc = i * dc + cmin;

const double phi[3] = { 1., 0., 0. };
double el = fchem(phil, &conc, temperature);
double ea = fchem(phia, &conc, temperature);
double eb = fchem(phib, &conc, temperature);

double e = fchem(phi, &conc, temperature);
os << conc << "\t" << e << std::endl;
}
os << std::endl << std::endl;

os << "#phi1=1" << std::endl;
for (int i = 0; i < npts; i++)
{
const double conc = i * dc + cmin;

const double phi[3] = { 0., 1., 0. };
double e = fchem(phi, &conc, temperature);
os << conc << "\t" << e << std::endl;
}
os << std::endl << std::endl;

os << "#phi2=1" << std::endl;
for (int i = 0; i < npts; i++)
{
const double conc = i * dc + cmin;

const double phi[3] = { 0., 0., 1. };
double e = fchem(phi, &conc, temperature);
os << conc << "\t" << e << std::endl;
os << conc << ", " << el << ", " << ea << ", " << eb << std::endl;
}
}

Expand Down
8 changes: 5 additions & 3 deletions utils/FvsCbinaryThreePhases.plt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set size 0.7,0.7
set output "FvsC.png"
set xlabel "Composition"
set ylabel "Energy (J/mol)"
set datafile separator ","
set key autotitle columnhead

plot 'FvsC.dat' i 0 u 1:2 t 'phase 1' w lines lw 2, \
'FvsC.dat' i 1 u 1:2 t 'phase 2' w lines lw 2, \
'FvsC.dat' i 2 u 1:2 t 'phase 3' w lines lw 2
plot 'FvsC.csv' u 1:2 t 'phase L' w lines lw 2, \
'FvsC.csv' u 1:3 t 'phase A' w lines lw 2, \
'FvsC.csv' u 1:4 t 'phase B' w lines lw 2

0 comments on commit 43c1611

Please sign in to comment.