Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
NDSolver.hh
Go to the documentation of this file.
1#pragma once
2
3#include "Storage.hh"
4#include "Compare.hh"
5#include "Exceptions.hh"
6#include "NTensor.hh"
7#include "NEvaluator.hh"
8
9namespace cadabra {
10
24
25 class NDSolver {
26 public:
27 // Initialise with an Ex containing the ODEs in standard form
28 // (that is, only 1st order derivatives on the lhs).
29 NDSolver(const Ex&);
30
31 typedef std::vector<double> state_type;
32
33 // Integration function.
34 void operator()(const state_type &x, state_type &dxdt, const double t);
35
36 // Observer function.
37 void operator()( const state_type &x , double t );
38
39 // Set and check ODE(s).
40 void set_ODEs(const Ex&);
41
42 // Set initial values.
43 void set_initial_value(const Ex&, double val);
44
45 // Set integration range for the independent variable.
46 void set_range(const Ex&, double from, double to);
47
48 // Entry point.
49 std::vector<NTensor> integrate();
50
51 private:
52 // Exception used by the observer function to terminate
53 // iteration in case an event happens.
54
55 class EventException : public CadabraException {
56 public:
57 EventException(std::string="");
58 };
59
60 Ex ODEs;
61
62 // Information extracted from `ODEs`.
63 std::vector<Ex> variables;
64
65 // For each function in the ODEs we have one evaluator.
66 std::vector<NEvaluator> evaluators;
67
68 // Extract from `ODEs` the right-hand side expressions as
69 // well as the names of the functions to solve for.
70 void extract_from_ODEs();
71
72 // Storage of the result of the integration.
73 std::vector<std::vector<double>> states;
74 std::vector<double> times;
75 std::map<Ex, double, tree_exact_less_no_wildcards_obj> initial_values;
77 double range_from, range_to;
78};
79
80};
Definition Exceptions.hh:7
Functions to handle the exchange properties of two or more symbols in a product.
Definition Adjform.cc:83
void set(rset_t::iterator &num, multiplier_t fac)
Definition Storage.cc:1064