diff options
author | Nao Pross <np@0hm.ch> | 2024-02-12 14:52:43 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-02-12 14:52:43 +0100 |
commit | eda5bc26f44ee9a6f83dcf8c91f17296d7fc509d (patch) | |
tree | bc2efa38ff4e350f9a111ac87065cd7ae9a911c7 /src/control.h.old | |
download | fsisotool-eda5bc26f44ee9a6f83dcf8c91f17296d7fc509d.tar.gz fsisotool-eda5bc26f44ee9a6f83dcf8c91f17296d7fc509d.zip |
Move into version control
Diffstat (limited to 'src/control.h.old')
-rw-r--r-- | src/control.h.old | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/src/control.h.old b/src/control.h.old new file mode 100644 index 0000000..3a147fc --- /dev/null +++ b/src/control.h.old @@ -0,0 +1,104 @@ +#pragma once + +#include "Eigen/Dense" +#include <complex> + +#ifndef CONTROL_H +#define CONTROL_H + + +namespace ct +{ + // Fwd declarations + template<typename T, int n, int m, int k> struct SSModel; + template<typename T, int p, int z> struct TransferFn; + + namespace math + { + template<typename T, int n, int m> + Eigen::Vector<T, n + m - 1> convolve1d( + const Eigen::Ref<Eigen::Vector<T, n>>& x + const Eigen::Ref<Eigen::Vector<T, m>>& y) + { + Eigen::Vector<T, n + m -1> out; + + return out; + } + + Eigen::VectorXd convolve1d( + const Eigen::Ref<Eigen::VectorXd>& x, + const Eigen::Ref<Eigen::VectorXd>& y) + { + + } + } + + /* Transfer Functions for SISO and frequency domain analysis */ + template<typename T, int p, int z> + struct TransferFn + { + Eigen::Vector<std::complex<T>, z> zeros; + Eigen::Vector<std::complex<T>, p> poles; + + explicit operator SSModel<T, p, 1, 1>() const + { + + } + }; + + typedef TransferFn<std::complex<double>, Eigen::Dynamic, Eigen::Dynamic> TransferFnXd; + + template<typename T, typename CT = std::complex<T>> + struct FreqSeries + { + size_t nsamples; + T start, end; + Eigen::VectorX<T> f; + Eigen::VectorX<CT> data; + }; + + typedef FreqSeries<double> FreqSeriesD; + + /* State space modelling and time domain simulaiton */ + + template<typename T, int n, int m, int k> + struct SSModel + { + /* State space model with + * - n dimensional state x + * - m dimensional input u + * - k dimensional output y + */ + Eigen::Matrix<T, n, n> A; + Eigen::Matrix<T, n, m> B; + Eigen::Matrix<T, k, m> C; + Eigen::Matrix<T, k, m> D; + + // SSModel(Eigen::VectorX<T> zeros, Eigen::VectorX<T> poles); + }; + + typedef SSModel<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic> SSModelXd; + + template<typename T> + struct TimeSeries + { + size_t nsamples; + T start, end; + Eigen::VectorX<T> t; + Eigen::MatrixX<T> u, x, y; + + template<int n, int m, int k> + explicit TimeSeries(size_t nsamples, T start, T end, const SSModel<T, n, m, k>& ss); + }; + + typedef TimeSeries<double> TimeSeriesD; + + template<typename T, int n, int m, int k> + void response(SSModel<T, n, m, k> ss, TimeSeries<T>& ts); + + template<typename T, int n, int m, int k> + void step(SSModel<T, n, m, k> ss, TimeSeries<T>& ts); +} + +#endif // CONTROL_H +// vim:ts=2 sw=2 noet: |