diff --git a/src/libcadet/CMakeLists.txt b/src/libcadet/CMakeLists.txt index e8cd0e485..aa8312a41 100644 --- a/src/libcadet/CMakeLists.txt +++ b/src/libcadet/CMakeLists.txt @@ -133,11 +133,7 @@ set(LIBCADET_SOURCES ${CMAKE_SOURCE_DIR}/src/libcadet/model/StirredTankModel.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/LumpedRateModelWithoutPores.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/LumpedRateModelWithPores.cpp -# ${CMAKE_SOURCE_DIR}/src/libcadet/model/LumpedRateModelWithPores-LinearSolver.cpp -# ${CMAKE_SOURCE_DIR}/src/libcadet/model/LumpedRateModelWithPores-InitialConditions.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/GeneralRateModel.cpp -# ${CMAKE_SOURCE_DIR}/src/libcadet/model/GeneralRateModel-LinearSolver.cpp -# ${CMAKE_SOURCE_DIR}/src/libcadet/model/GeneralRateModel-InitialConditions.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/ParameterMultiplexing.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/parts/ConvectionDispersionOperator.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/parts/AxialConvectionDispersionKernel.cpp @@ -150,6 +146,7 @@ set(LIBCADET_SOURCES ${CMAKE_SOURCE_DIR}/src/libcadet/model/paramdep/ParameterDependenceBase.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/paramdep/LiquidSaltSolidParameterDependence.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/paramdep/DummyParameterDependence.cpp + ${CMAKE_SOURCE_DIR}/src/libcadet/model/paramdep/IdentityParameterDependence.cpp ${CMAKE_SOURCE_DIR}/src/libcadet/model/paramdep/PowerLawParameterDependence.cpp ) diff --git a/src/libcadet/ParameterDependenceFactory.cpp b/src/libcadet/ParameterDependenceFactory.cpp index 359cdd14d..ad165dfe9 100644 --- a/src/libcadet/ParameterDependenceFactory.cpp +++ b/src/libcadet/ParameterDependenceFactory.cpp @@ -22,6 +22,8 @@ namespace cadet void registerLiquidSaltSolidParamDependence(std::unordered_map>& paramDeps); void registerDummyParamDependence(std::unordered_map>& paramDeps); void registerDummyParamDependence(std::unordered_map>& paramDeps); + void registerIdentityParamDependence(std::unordered_map>& paramDeps); + void registerIdentityParamDependence(std::unordered_map>& paramDeps); void registerPowerLawParamDependence(std::unordered_map>& paramDeps); } } @@ -31,9 +33,11 @@ namespace cadet // Register all ParamState dependencies model::paramdep::registerLiquidSaltSolidParamDependence(_paramStateDeps); model::paramdep::registerDummyParamDependence(_paramStateDeps); + model::paramdep::registerIdentityParamDependence(_paramStateDeps); // Register all ParamParam dependencies model::paramdep::registerDummyParamDependence(_paramParamDeps); + model::paramdep::registerIdentityParamDependence(_paramParamDeps); model::paramdep::registerPowerLawParamDependence(_paramParamDeps); } diff --git a/src/libcadet/model/paramdep/IdentityParameterDependence.cpp b/src/libcadet/model/paramdep/IdentityParameterDependence.cpp new file mode 100644 index 000000000..60092ed6b --- /dev/null +++ b/src/libcadet/model/paramdep/IdentityParameterDependence.cpp @@ -0,0 +1,141 @@ +// ============================================================================= +// CADET +// +// Copyright ┬® 2008-2022: The CADET Authors +// Please see the AUTHORS and CONTRIBUTORS file. +// +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the GNU Public License v3.0 (or, at +// your option, any later version) which accompanies this distribution, and +// is available at http://www.gnu.org/licenses/gpl.html +// ============================================================================= + +#include "model/paramdep/ParameterDependenceBase.hpp" +#include "ParamReaderHelper.hpp" +#include "cadet/Exceptions.hpp" +#include "SimulationTypes.hpp" +#include "cadet/ParameterId.hpp" + +#include +#include +#include + +namespace cadet +{ + +namespace model +{ + +/** + * @brief Defines an identity parameter dependence + */ +class IdentityParameterStateDependence : public ParameterStateDependenceBase +{ +public: + + IdentityParameterStateDependence() { } + virtual ~IdentityParameterStateDependence() CADET_NOEXCEPT { } + + static const char* identifier() { return "IDENTITY"; } + virtual const char* name() const CADET_NOEXCEPT { return IdentityParameterStateDependence::identifier(); } + + virtual int jacobianElementsPerRowLiquid() const CADET_NOEXCEPT { return 0; } + virtual int jacobianElementsPerRowCombined() const CADET_NOEXCEPT { return 0; } + + virtual void analyticJacobianLiquidAdd(const ColumnPosition& colPos, double param, double const* y, int comp, double factor, int offset, int row, linalg::DoubleSparseMatrix& jac) const { } + virtual void analyticJacobianCombinedAddLiquid(const ColumnPosition& colPos, double param, double const* yLiquid, double const* ySolid, int comp, double factor, int offset, int row, linalg::DoubleSparseMatrix& jac) const { } + virtual void analyticJacobianCombinedAddSolid(const ColumnPosition& colPos, double param, double const* yLiquid, double const* ySolid, int bnd, double factor, int offset, int row, linalg::DoubleSparseMatrix& jac) const { } + + CADET_PARAMETERSTATEDEPENDENCE_BOILERPLATE + +protected: + + virtual bool configureImpl(IParameterProvider& paramProvider, UnitOpIdx unitOpIdx, ParticleTypeIdx parTypeIdx, const std::string& name) + { + return true; + } + + template + typename DoubleActivePromoter::type liquidParameterImpl(const ColumnPosition& colPos, const ParamType& param, StateType const* y, int comp) const + { + return param; + } + + template + void analyticJacobianLiquidAddImpl(const ColumnPosition& colPos, double param, double const* y, int comp, double factor, int offset, RowIterator jac) const { } + + template + typename DoubleActivePromoter::type combinedParameterLiquidImpl(const ColumnPosition& colPos, const ParamType& param, StateType const* yLiquid, StateType const* ySolid, int comp) const + { + return param; + } + + template + void analyticJacobianCombinedAddLiquidImpl(const ColumnPosition& colPos, double param, double const* yLiquid, double const* ySolid, int comp, double factor, int offset, RowIterator jac) const { } + + template + typename DoubleActivePromoter::type combinedParameterSolidImpl(const ColumnPosition& colPos, const ParamType& param, StateType const* yLiquid, StateType const* ySolid, int bnd) const + { + return param; + } + + template + void analyticJacobianCombinedAddSolidImpl(const ColumnPosition& colPos, double param, double const* yLiquid, double const* ySolid, int bnd, double factor, int offset, RowIterator jac) const { } +}; + + +/** + * @brief Defines an identity parameter dependence + */ +class IdentityParameterParameterDependence : public ParameterParameterDependenceBase +{ +public: + + IdentityParameterParameterDependence() { } + virtual ~IdentityParameterParameterDependence() CADET_NOEXCEPT { } + + static const char* identifier() { return "IDENTITY"; } + virtual const char* name() const CADET_NOEXCEPT { return IdentityParameterParameterDependence::identifier(); } + + CADET_PARAMETERPARAMETERDEPENDENCE_BOILERPLATE + +protected: + + virtual bool configureImpl(IParameterProvider& paramProvider, UnitOpIdx unitOpIdx, ParticleTypeIdx parTypeIdx, BoundStateIdx bndIdx, const std::string& name) + { + return true; + } + + template + ParamType getValueImpl(const IModel& model, const ColumnPosition& colPos, int comp, int parType, int bnd) const + { + return 0.0; + } + + template + ParamType getValueImpl(const IModel& model, const ColumnPosition& colPos, int comp, int parType, int bnd, const ParamType& val) const + { + return val; + } + +}; + + +namespace paramdep +{ + void registerIdentityParamDependence(std::unordered_map>& paramDeps) + { + paramDeps[IdentityParameterStateDependence::identifier()] = []() { return new IdentityParameterStateDependence(); }; + paramDeps["NONE"] = []() { return new IdentityParameterStateDependence(); }; + } + + void registerIdentityParamDependence(std::unordered_map>& paramDeps) + { + paramDeps[IdentityParameterParameterDependence::identifier()] = []() { return new IdentityParameterParameterDependence(); }; + paramDeps["NONE"] = []() { return new IdentityParameterParameterDependence(); }; + } +} // namespace paramdep + +} // namespace model + +} // namespace cadet