Skip to content

Commit

Permalink
[samples] Remove redundant headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed May 10, 2022
1 parent a00592e commit 2aca6e7
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 46 deletions.
1 change: 0 additions & 1 deletion include/cantera/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef CT_INCL_CORE_H
#define CT_INCL_CORE_H

// #include "cantera/base/global.h"
#include "cantera/base/Solution.h"
#include "cantera/thermo/ThermoPhase.h"
#include "cantera/kinetics/Kinetics.h"
Expand Down
6 changes: 3 additions & 3 deletions samples/cxx/LiC6_electrode/LiC6_electrode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.

#include "cantera/thermo.h"
#include "cantera/core.h"
#include <iostream>
#include <fstream>

using namespace Cantera;

void calc_potentials()
{
suppress_deprecation_warnings();
double Tk = 273.15 + 25.0;

std::string filename = "LiC6_electrodebulk.yaml";
std::string phasename = "LiC6_and_Vacancies";
std::unique_ptr<ThermoPhase> electrodebulk(newPhase(filename,phasename));
auto sol = newSolution(filename, phasename);
auto electrodebulk = sol->thermo();
std::string intercalatingSpeciesName("Li(C6)");
size_t intercalatingSpeciesIdx = electrodebulk->speciesIndex(intercalatingSpeciesName);
size_t nsp_tot = electrodebulk->nSpecies();
Expand Down
2 changes: 0 additions & 2 deletions samples/cxx/combustor/combustor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
// at https://cantera.org/license.txt for license and copyright information.

#include "cantera/zerodim.h"
#include "cantera/thermo/IdealGasPhase.h"

#include <fstream>

using namespace Cantera;
Expand Down
16 changes: 7 additions & 9 deletions samples/cxx/custom/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.

#include "cantera/thermo.h"
#include "cantera/kinetics.h"
#include "cantera/base/Solution.h"
#include "cantera/core.h"
#include "cantera/numerics/Integrator.h"
#include <fstream>

Expand Down Expand Up @@ -75,7 +73,7 @@ class ReactorODEs : public FuncEval {
double *massFracs = &y[1];
double *dTdt = &ydot[0];
double *dYdt = &ydot[1];

/* ------------------------- UPDATE GAS STATE ------------------------- */
// the state of the ThermoPhase is updated to reflect the current solution
// vector, which was calculated by the integrator.
Expand All @@ -87,7 +85,7 @@ class ReactorODEs : public FuncEval {
double cp = m_gas->cp_mass();
m_gas->getPartialMolarEnthalpies(&m_hbar[0]);
m_kinetics->getNetProductionRates(&m_wdot[0]);

/* -------------------------- ENERGY EQUATION ------------------------- */
// the rate of change of the system temperature is found using the energy
// equation for a closed-system constant pressure ideal gas:
Expand All @@ -110,7 +108,7 @@ class ReactorODEs : public FuncEval {
dYdt[k] = m_wdot[k] * m_gas->molecularWeight(k) / rho;
}
}

/**
* Number of equations in the ODE system.
* - overridden from FuncEval, called by the integrator during initialization.
Expand Down Expand Up @@ -153,7 +151,7 @@ int main() {
// for each simulation time point.
// create the csv file, overwriting any existing ones with the same name.
std::ofstream outputFile("custom_cxx.csv");

// for convenience, a title for each of the state vector's components is written to
// the first line of the csv file.
outputFile << "time (s), temp (K)";
Expand All @@ -171,7 +169,7 @@ int main() {
// the new absolute time of the system.
double tnow = 0.0;
double tfinal = 1e-3;

/* ------------------- CREATE & INIT ODE INTEGRATOR ------------------- */
// create an ODE integrator object, which will be used to solve the system of ODES defined
// in the ReactorODEs class. a C++ interface to the C-implemented SUNDIALS CVODES integrator
Expand All @@ -188,7 +186,7 @@ int main() {
// internally, the integrator will apply settings, allocate needed memory, and populate
// this memory with the appropriate initial values for the system.
integrator->initialize(tnow, odes);

/* ----------------------- SIMULATION TIME LOOP ----------------------- */
while (tnow < tfinal) {
// advance the simulation to the current absolute time, tnow, using the integrator's
Expand Down
9 changes: 4 additions & 5 deletions samples/cxx/demo/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
// provide a simplified interface to the Cantera header files. If you need
// to include core headers directly, use the format "cantera/module/*.h".

#include "cantera/thermo/IdealGasPhase.h" // defines class IdealGasPhase
#include "cantera/base/Solution.h"
#include "cantera/kinetics/GasKinetics.h"
#include "cantera/transport.h" // transport properties
#include "cantera/core.h"
#include "cantera/base/global.h" // provides Cantera::writelog
#include <iostream>

// All Cantera kernel names are in namespace Cantera. You can either
Expand Down Expand Up @@ -98,7 +96,8 @@ void demoprog()

// create a transport manager for the gas that computes
// mixture-averaged properties
std::unique_ptr<Transport> tr(newTransportMgr("Mix", sol->thermo().get()));
sol->setTransport("mixture-averaged");
auto tr = sol->transport();

// print the viscosity, thermal conductivity, and diffusion
// coefficients
Expand Down
16 changes: 5 additions & 11 deletions samples/cxx/flamespeed/flamespeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.

#include "cantera/oneD/Sim1D.h"
#include "cantera/oneD/Boundary1D.h"
#include "cantera/oneD/StFlow.h"
#include "cantera/thermo/IdealGasPhase.h"
#include "cantera/transport.h"
#include "cantera/base/Solution.h"
#include "cantera/onedim.h"
#include "cantera/base/stringUtils.h"
#include <fstream>

Expand Down Expand Up @@ -75,10 +70,8 @@ int flamespeed(double phi, bool refine_grid, int loglevel)
// specify the objects to use to compute kinetic rates and
// transport properties

std::unique_ptr<Transport> trmix(newTransportMgr("Mix", sol->thermo().get()));
std::unique_ptr<Transport> trmulti(newTransportMgr("Multi", sol->thermo().get()));

flow.setTransport(*trmix);
sol->setTransport("mixture-averaged");
flow.setTransport(*sol->transport());
flow.setKinetics(*sol->kinetics());
flow.setPressure(pressure);

Expand Down Expand Up @@ -145,7 +138,8 @@ int flamespeed(double phi, bool refine_grid, int loglevel)
flameSpeed_mix);

// now switch to multicomponent transport
flow.setTransport(*trmulti);
sol->setTransport("multicomponent");
flow.setTransport(*sol->transport());
flame.solve(loglevel, refine_grid);
double flameSpeed_multi = flame.value(flowdomain,
flow.componentIndex("velocity"),0);
Expand Down
17 changes: 7 additions & 10 deletions samples/cxx/gas_transport/gas_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.

#include "cantera/thermo.h"
#include "cantera/transport.h"
#include "cantera/base/Solution.h"
#include "cantera/core.h"
#include "cantera/base/Array.h"
#include "cantera/base/plots.h"

#include <fstream>
#include <iostream>

using namespace Cantera;
Expand Down Expand Up @@ -85,18 +83,17 @@ void transport_example()
// Save transport properties to a file
write_csv("transport_mix.csv", labels, output);

// Create a new transport manager for multicomponent properties
unique_ptr<Transport> multi(
newTransportMgr("multicomponent", sol->thermo().get()));
// Switch transport manager to multicomponent properties
sol->setTransport("multicomponent");

// Get multicomponent properties at several temperatures
for (int i = 0; i < ntemps; i++) {
temp = 500.0 + 100.0*i;
gas->setState_TP(temp, pres);
output(0,i) = temp;
output(1,i) = multi->viscosity();
output(2,i) = multi->thermalConductivity();
multi->getThermalDiffCoeffs(&output(3,i));
output(1,i) = sol->transport()->viscosity();
output(2,i) = sol->transport()->thermalConductivity();
sol->transport()->getThermalDiffCoeffs(&output(3,i));
}

// Save transport properties to a file
Expand Down
4 changes: 1 addition & 3 deletions samples/cxx/jacobian/derivative_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include <iostream>
#include <iomanip>
#include <numeric>
#include "cantera/base/Solution.h"
#include "cantera/thermo/IdealGasPhase.h"
#include "cantera/kinetics.h"
#include "cantera/core.h"
#include "cantera/numerics/eigen_sparse.h"

using namespace Cantera;
Expand Down
1 change: 0 additions & 1 deletion samples/cxx/kinetics1/kinetics1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// at https://cantera.org/license.txt for license and copyright information.

#include "cantera/zerodim.h"
#include "cantera/thermo/IdealGasPhase.h"
#include "cantera/numerics/Integrator.h"
#include "example_utils.h"

Expand Down
1 change: 0 additions & 1 deletion samples/cxx/openmp_ignition/openmp_ignition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// at https://cantera.org/license.txt for license and copyright information.

#include "cantera/zerodim.h"
#include "cantera/thermo/IdealGasPhase.h"

#include <omp.h>

Expand Down

0 comments on commit 2aca6e7

Please sign in to comment.