numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
implicit_kaps_problem.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <Eigen/Core>
23
27
28namespace num_prob_collect::ode {
29
51public:
53 using variable_type = Eigen::Vector2d;
54
56 using scalar_type = double;
57
59 using jacobian_type = Eigen::Matrix2d;
60
62 using mass_type = Eigen::Matrix2d;
63
65 static constexpr auto allowed_evaluations =
67 .diff_coeff = true, .jacobian = true, .mass = true};
68
74 explicit implicit_kaps_problem(double epsilon)
75 : epsilon_(epsilon), mass_({{epsilon_, 0.0}, {0.0, 1.0}}) {}
76
83 void evaluate_on(double /*time*/, const variable_type& variable,
85 diff_coeff_(0) = -(1.0 + 2.0 * epsilon_) * variable(0) + // NOLINT
86 variable(1) * variable(1);
87 diff_coeff_(1) = variable(0) - variable(1) - variable(1) * variable(1);
88
89 if (evaluations.jacobian) {
90 jacobian_(0, 0) = -(1.0 + 2.0 * epsilon_); // NOLINT
91 jacobian_(0, 1) = 2.0 * variable(1); // NOLINT
92 jacobian_(1, 0) = 1.0;
93 jacobian_(1, 1) = -1.0 - 2.0 * variable(1); // NOLINT
94 }
95 }
96
102 [[nodiscard]] auto diff_coeff() const noexcept -> const variable_type& {
103 return diff_coeff_;
104 }
105
111 [[nodiscard]] auto jacobian() const noexcept -> const jacobian_type& {
112 return jacobian_;
113 }
114
120 [[nodiscard]] auto mass() const noexcept -> const mass_type& {
121 return mass_;
122 }
123
124private:
126 double epsilon_;
127
130
133
136};
137
139 implicit_kaps_problem>);
141
142} // namespace num_prob_collect::ode
Eigen::Matrix2d jacobian_type
Type of Jacobian.
void evaluate_on(double, const variable_type &variable, num_collect::ode::evaluation_type evaluations)
Evaluate on a (time, variable) pair.
variable_type diff_coeff_
Differential coefficient.
static constexpr auto allowed_evaluations
Allowed evaluations.
auto mass() const noexcept -> const mass_type &
Get the mass.
auto jacobian() const noexcept -> const jacobian_type &
Get the Jacobian.
auto diff_coeff() const noexcept -> const variable_type &
Get the differential coefficient.
Eigen::Vector2d variable_type
Type of variables.
Concept of problems of ordinary differential equations with mass.
Concept of problems of multi-variate differentiable ordinary differential equations.
Definition of evaluation_type enumeration.
Definition of mass_problem concept.
Definition of multi_variate_differentiable_problem concept.
Namespace of ordinary differential equation problems.
Definition namespaces.h:28
Struct to specify types of evaluations.