[Echempp-devel] Experiment/Data Data.cpp, NONE, 1.1 Data.hpp, NONE, 1.1 Makefile.am, 1.10, 1.11
Status: Beta
Brought to you by:
berndspeiser
|
From: beeblbrox <bee...@us...> - 2007-12-19 13:24:59
|
Update of /cvsroot/echempp/Experiment/Data In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv30911/Experiment/Data Modified Files: Makefile.am Added Files: Data.cpp Data.hpp Log Message: ConditionData and MeasurementData classes. --- NEW FILE: Data.cpp --- #include "Data.hpp" namespace experiment { const std::string MeasurementData::GUID = "MeasurementData"; const std::string MeasurementDataModSim::GUID = "MeasurementDataModSim"; const std::string ConditionData::GUID = "ConditionData"; const std::string SolverConditions::GUID = "SolverConditions"; const std::string ConditionDataModSim::GUID = "ConditionDataModSim"; } // end namespace experiment --- NEW FILE: Data.hpp --- /*! \file Data.hpp \brief header file for all data related classes. Data.hpp is part of the Experiment package. */ /* Copyright (C) 2007, Dominik Brugger This file is part of EChem++. EChem++ is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. EChem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id: Data.hpp,v 1.1 2007/12/19 13:24:54 beeblbrox Exp $ #ifndef __DATA_HPP__ #define __DATA_HPP__ // STL includes #include <vector> #include <map> #include <set> #include <iostream> #include <algorithm> // BSUtilities includes #include "SerializationTools.h" // local includes #include "ExcitationFunction/ecExcitationFunctions.hpp" #include "../../GUI/Windows/Qt/EChem++/Model/quantityTypes.hpp" // Boost includes #include <boost/serialization/serialization.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/set.hpp> #include <boost/serialization/base_object.hpp> namespace experiment{ //! DataPoint represents one point of measurement data, that //! is a tuple of independent, dependent and result variable. //! Note: So far not used, since the simulator does not strictly //! use I,D,R template<class I, class D, class R> class DataPoint { public: DataPoint(const I i, const D d, const R r) : _i(i), _d(d), _r(r) {}; const I fst() const { return _i; } const D snd() const { return _d; } const R trd() const { return _r; } private: DataPoint(){} I _i; D _d; R _r; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(_i) & BOOST_SERIALIZATION_NVP(_d) & BOOST_SERIALIZATION_NVP(_r); } }; //! Class to represent a measurement, that is a sequence //! of DataPoint. //! Note: Not used so far, since the simulator does not respect //! I,D,R template<class I, class D, class R> class Measurement { public: typedef DataPoint<I,D,R> point_type; Measurement() {} Measurement(const std::vector<point_type>& data) : _data(data) {} void add(const point_type& p) { _data.push_back(p); } const size_t size() const { return _data.size(); } private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(_data); } std::vector<point_type> _data; }; //! Base class for all measurement data. //! Measurement data produced by the simulator is //! represented by MeasurementDataModSim. class MeasurementData { public: BSUtilities::Serialization::AutoRegistor<MeasurementData> reg; static const std::string GUID; //! Create a deep copy of MeasurementData virtual MeasurementData* clone() { return new MeasurementData(*this); } virtual ~MeasurementData() {} private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version){} }; //! MeasurementDataModSim contains the measurement, e.g. current-time //! curves produced by the simulator. class MeasurementDataModSim : public MeasurementData { public: // default copy ctor ok //! Create a deep copy of MeasurementDataModSim MeasurementDataModSim* clone() { return new MeasurementDataModSim(*this); } BSUtilities::Serialization::AutoRegistor<MeasurementDataModSim> reg; static const std::string GUID; // TODO: Replace later by Measurement //! Response curve produced by simulator std::vector<std::vector<double> > responseCurves; //! Time steps used by simulator, note that these are //! non-uniform since it uses an adaptive FEM for solution. std::vector<double> timeSteps; //! Conversion factor used for dimensionless variables double conversionFactor; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(MeasurementData) & BOOST_SERIALIZATION_NVP(responseCurves) & BOOST_SERIALIZATION_NVP(timeSteps) & BOOST_SERIALIZATION_NVP(conversionFactor); } }; //! Base class for all condition data. Condition data used //! by the simulator is represented by ConditionDataModSim. class ConditionData { public: BSUtilities::Serialization::AutoRegistor<ConditionData> reg; static const std::string GUID; //! Create a deep copy of ConditionData. virtual ConditionData* clone() { return new ConditionData(*this); } virtual ~ConditionData() {} private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version){} }; // data from solver dialog class SolverConditions { public: BSUtilities::Serialization::AutoRegistor<SolverConditions> reg; static const std::string GUID; enum Processor { PLAIN, STORAGE, DYNAMIC }; double rho; double TOL; std::vector<double> ATOLs; std::vector<double> RTOLs; double resATOL; double resRTOL; double initTime; double initConcTol; double initStepSize; double maxStepSize; GUI::model::uint_t maxRej; double shrink; double growth; double safety; GUI::model::uint_t maxLevel; double gamma; double theta; double alpha; double mue; double k1; double k2; GUI::model::uint_t noElements; GUI::model::uint_t noRefinements; std::string timeScheme; std::string timeController; GUI::model::uint_t activeBoundaries; bool stepPolicy; bool autoTols; bool fixed; bool residuum; bool gradient; Processor type; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(rho) & BOOST_SERIALIZATION_NVP(TOL) & BOOST_SERIALIZATION_NVP(ATOLs) & BOOST_SERIALIZATION_NVP(RTOLs) & BOOST_SERIALIZATION_NVP(resATOL) & BOOST_SERIALIZATION_NVP(resRTOL) & BOOST_SERIALIZATION_NVP(initTime) & BOOST_SERIALIZATION_NVP(initConcTol) & BOOST_SERIALIZATION_NVP(initStepSize) & BOOST_SERIALIZATION_NVP(maxStepSize) & BOOST_SERIALIZATION_NVP(maxRej) & BOOST_SERIALIZATION_NVP(shrink) & BOOST_SERIALIZATION_NVP(growth) & BOOST_SERIALIZATION_NVP(safety) & BOOST_SERIALIZATION_NVP(maxLevel) & BOOST_SERIALIZATION_NVP(gamma) & BOOST_SERIALIZATION_NVP(theta) & BOOST_SERIALIZATION_NVP(alpha) & BOOST_SERIALIZATION_NVP(mue) & BOOST_SERIALIZATION_NVP(k1) & BOOST_SERIALIZATION_NVP(k2) & BOOST_SERIALIZATION_NVP(noElements) & BOOST_SERIALIZATION_NVP(noRefinements) & BOOST_SERIALIZATION_NVP(timeScheme) & BOOST_SERIALIZATION_NVP(timeController) & BOOST_SERIALIZATION_NVP(activeBoundaries) & BOOST_SERIALIZATION_NVP(stepPolicy) & BOOST_SERIALIZATION_NVP(autoTols) & BOOST_SERIALIZATION_NVP(fixed) & BOOST_SERIALIZATION_NVP(residuum) & BOOST_SERIALIZATION_NVP(gradient) & BOOST_SERIALIZATION_NVP(type); } }; //! ConditionDataModSim collects all the conditions used by //! the simulator, which are accessible through the GUI in the //! various dialogs. The parameters used for the FEM solver are //! collected in SolverConditions. class ConditionDataModSim : public ConditionData { public: // Default copy ctor ok ConditionDataModSim* clone() { return new ConditionDataModSim(*this); } BSUtilities::Serialization::AutoRegistor<ConditionDataModSim> reg; static const std::string GUID; // data from experiment dialog double safety; bool is_finite; bool currentControlled; bool potentialControlled; quantity::Length finiteDistance; int num_electrodes; int dimension; std::string technique0; std::string technique1; int boundary0; int boundary1; ExcitationFunctions::EtExcitationFunction etExcitation0; ExcitationFunctions::EtExcitationFunction etExcitation1; ExcitationFunctions::itExcitationFunction itExcitation0; ExcitationFunctions::itExcitationFunction itExcitation1; // data from mechanism dialog bool chargeBalance; bool stoichiometricBalance; std::string mechanism; std::set<int> activeBoundaries; // data from model parameters dialog //! temperature quantity::ThermodynamicTemperature temp; //! electrode area quantity::Area area; //! map of concentrations //! key = species index GUI::model::ConcentrationMap dissConcs; quantity::Concentration refDissConc; int refConcIndex; //! map of surface concentrations //! key = species index GUI::model::SurfaceConcentrationMap adsConcs; //! map of surface concentrations //! key = boundary index GUI::model::SaturationConcentrationMap saturationConcs; //! map of diffusion coefficients //! key = species index GUI::model::DiffusionCoefficientMap diffCoeffs; quantity::DiffusionCoefficient refDiffCoeff; int maxDiffCoeff; //! map of formal potentials. //! key = reactions index GUI::model::ElectricPotentialMap formalPotentials; //! map of ET coefficients (Butler Volmer law) //! key = reaction index std::map<GUI::model::uint_t,double> alphas; //! map of heterogeneous rate constants. //! key = reaction index GUI::model::HeterogeneousRateConstantMap khs; //! map of Langmuir equilibrium constants. //! key = reaction index GUI::model::LangmuirEquilibriumConstantMap langEquilConstants; //! map of Langmuir adsorption rate constants //! key = reaction index GUI::model::LangmuirAdsorptionRateConstantMap langAdsRateConstants; //! map of first order rate constants //! key = reaction index GUI::model::FirstOrderRateConstantMap firstOrderRateConstants; //! key = reaction index std::map<GUI::model::uint_t,double> homEquilibriumConstants; std::map<GUI::model::uint_t,double> homForwardRateConstants; std::map<GUI::model::uint_t,double> homBackwardRateConstants; std::map<GUI::model::uint_t,double> homSurfEquilibriumConstants; std::map<GUI::model::uint_t,double> homSurfForwardRateConstants; std::map<GUI::model::uint_t,double> homSurfBackwardRateConstants; std::map<GUI::model::uint_t,double> hetSurfEquilibriumConstants; std::map<GUI::model::uint_t,double> hetSurfForwardRateConstants; std::map<GUI::model::uint_t,double> hetSurfBackwardRateConstants; //! indices of fixed thermodynamic paramters std::set<GUI::model::uint_t> fixed; unsigned int numRowsDissSpecies; unsigned int numRowsAdsSpecies; unsigned int numRowsSaturation; unsigned int numRowsBvDiss; unsigned int numRowsBvAds; unsigned int numRowsLangmuir; unsigned int numRowsHomPower; unsigned int numRowsHomGen; unsigned int numColsHomGen; unsigned int numRowsHomSurfPower; unsigned int numRowsHomSurfGen; unsigned int numColsHomSurfGen; unsigned int numRowsHetSurfPower; unsigned int numRowsHetSurfGen; unsigned int numColsHetSurfGen; std::map<std::string, std::map<GUI::model::uint_t,std::vector<GUI::model::uint_t> > > genParams; //! Key = col in homGenericTable and surfGenericTable (shifted by -1), //! value = name of parameter std::map<int,std::string> genColsParams; //! Key = name of parameter, value = col in homGenericTable and surfGenericTable (shifted by -1) std::map<std::string,int> genParamsCols; std::map<std::string,double> genParamsValues; // data from equilibrium dialog double maxTime; double accuracy; bool dataStorage; double initStepSize; std::map<GUI::model::uint_t,double> cinit; std::map<GUI::model::uint_t,double> equConcs; std::set<GUI::model::uint_t> indices; std::vector<double> timeSteps; //! concentration profiles: Key = species index std::map<GUI::model::uint_t, std::vector<double> > profiles; bool homReactions; bool ads; bool homSurfReactions; bool hetSurfReactions; bool plotDiss; bool plotAds; // data from solver dialog SolverConditions sc; // data form data dialog bool visResponse; bool visSurfaceConc; bool visStepSizes; bool visTimeErrors; bool visDof; bool visSpatialErrors; bool visGridEvolution; bool visConcProfiles; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(ConditionData) & BOOST_SERIALIZATION_NVP(safety) & BOOST_SERIALIZATION_NVP(is_finite) & BOOST_SERIALIZATION_NVP(currentControlled) & BOOST_SERIALIZATION_NVP(potentialControlled) & BOOST_SERIALIZATION_NVP(finiteDistance) & BOOST_SERIALIZATION_NVP(num_electrodes) & BOOST_SERIALIZATION_NVP(dimension) & BOOST_SERIALIZATION_NVP(technique0) & BOOST_SERIALIZATION_NVP(technique1) & BOOST_SERIALIZATION_NVP(boundary0) & BOOST_SERIALIZATION_NVP(boundary1) & BOOST_SERIALIZATION_NVP(etExcitation0) & BOOST_SERIALIZATION_NVP(etExcitation1) & BOOST_SERIALIZATION_NVP(itExcitation0) & BOOST_SERIALIZATION_NVP(itExcitation1) & BOOST_SERIALIZATION_NVP(chargeBalance) & BOOST_SERIALIZATION_NVP(stoichiometricBalance) & BOOST_SERIALIZATION_NVP(mechanism) & BOOST_SERIALIZATION_NVP(activeBoundaries) & BOOST_SERIALIZATION_NVP(temp) & BOOST_SERIALIZATION_NVP(area) & BOOST_SERIALIZATION_NVP(dissConcs) & BOOST_SERIALIZATION_NVP(refDissConc) & BOOST_SERIALIZATION_NVP(refConcIndex) & BOOST_SERIALIZATION_NVP(adsConcs) & BOOST_SERIALIZATION_NVP(saturationConcs) & BOOST_SERIALIZATION_NVP(diffCoeffs) & BOOST_SERIALIZATION_NVP(refDiffCoeff) & BOOST_SERIALIZATION_NVP(maxDiffCoeff) & BOOST_SERIALIZATION_NVP(formalPotentials) & BOOST_SERIALIZATION_NVP(alphas) & BOOST_SERIALIZATION_NVP(khs) & BOOST_SERIALIZATION_NVP(langEquilConstants) & BOOST_SERIALIZATION_NVP(langAdsRateConstants) & BOOST_SERIALIZATION_NVP(firstOrderRateConstants) & BOOST_SERIALIZATION_NVP(homEquilibriumConstants) & BOOST_SERIALIZATION_NVP(homForwardRateConstants) & BOOST_SERIALIZATION_NVP(homBackwardRateConstants) & BOOST_SERIALIZATION_NVP(homSurfEquilibriumConstants) & BOOST_SERIALIZATION_NVP(homSurfForwardRateConstants) & BOOST_SERIALIZATION_NVP(homSurfBackwardRateConstants) & BOOST_SERIALIZATION_NVP(hetSurfEquilibriumConstants) & BOOST_SERIALIZATION_NVP(hetSurfForwardRateConstants) & BOOST_SERIALIZATION_NVP(hetSurfBackwardRateConstants) & BOOST_SERIALIZATION_NVP(fixed) & BOOST_SERIALIZATION_NVP(numRowsDissSpecies) & BOOST_SERIALIZATION_NVP(numRowsAdsSpecies) & BOOST_SERIALIZATION_NVP(numRowsSaturation) & BOOST_SERIALIZATION_NVP(numRowsBvDiss) & BOOST_SERIALIZATION_NVP(numRowsBvAds) & BOOST_SERIALIZATION_NVP(numRowsLangmuir) & BOOST_SERIALIZATION_NVP(numRowsHomPower) & BOOST_SERIALIZATION_NVP(numRowsHomGen) & BOOST_SERIALIZATION_NVP(numColsHomGen) & BOOST_SERIALIZATION_NVP(numRowsHomSurfPower) & BOOST_SERIALIZATION_NVP(numRowsHomSurfGen) & BOOST_SERIALIZATION_NVP(numColsHomSurfGen) & BOOST_SERIALIZATION_NVP(numRowsHetSurfPower) & BOOST_SERIALIZATION_NVP(numRowsHetSurfGen) & BOOST_SERIALIZATION_NVP(numColsHetSurfGen) & BOOST_SERIALIZATION_NVP(genParams) & BOOST_SERIALIZATION_NVP(genColsParams) & BOOST_SERIALIZATION_NVP(genParamsCols) & BOOST_SERIALIZATION_NVP(genParamsValues) & BOOST_SERIALIZATION_NVP(maxTime) & BOOST_SERIALIZATION_NVP(accuracy) & BOOST_SERIALIZATION_NVP(dataStorage) & BOOST_SERIALIZATION_NVP(initStepSize) & BOOST_SERIALIZATION_NVP(cinit) & BOOST_SERIALIZATION_NVP(equConcs) & BOOST_SERIALIZATION_NVP(indices) & BOOST_SERIALIZATION_NVP(timeSteps) & BOOST_SERIALIZATION_NVP(profiles) & BOOST_SERIALIZATION_NVP(homReactions) & BOOST_SERIALIZATION_NVP(ads) & BOOST_SERIALIZATION_NVP(homSurfReactions) & BOOST_SERIALIZATION_NVP(hetSurfReactions) & BOOST_SERIALIZATION_NVP(plotDiss) & BOOST_SERIALIZATION_NVP(plotAds) & BOOST_SERIALIZATION_NVP(sc) & BOOST_SERIALIZATION_NVP(visResponse) & BOOST_SERIALIZATION_NVP(visSurfaceConc) & BOOST_SERIALIZATION_NVP(visStepSizes) & BOOST_SERIALIZATION_NVP(visTimeErrors) & BOOST_SERIALIZATION_NVP(visDof) & BOOST_SERIALIZATION_NVP(visSpatialErrors) & BOOST_SERIALIZATION_NVP(visGridEvolution) & BOOST_SERIALIZATION_NVP(visConcProfiles); } }; } // end namespace experiment #endif Index: Makefile.am =================================================================== RCS file: /cvsroot/echempp/Experiment/Data/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile.am 23 Feb 2007 12:10:26 -0000 1.10 --- Makefile.am 19 Dec 2007 13:24:54 -0000 1.11 *************** *** 15,18 **** --- 15,20 ---- libeppData_la_SOURCES = data.hpp \ data.cpp \ + Data.hpp \ + Data.cpp \ dataError.hpp\ generalData.hpp\ |