421 this.
registerProps(
" A ",
" f ",
" B ",
" C ",
" x0 ",
" Inputs ",
" Params ",
" MaxTimestep ",
" StateScaling ");
434 rsys = models.ReducedSystem(rmodel);
447 if isempty(mu) && ~isempty(this.
Params)
448 error(
" A model with parameters cannot be simulated without a parameter argument. ");
451 error(
" The mu vector size mismatches the defined parameter number. ");
455 if isempty(inputidx) && ~isempty(this.
Inputs)
456 cprintf(
" red ",
" Attention: Starting simulations without input, but the system has configured some.\n ");
458 elseif inputidx > length(this.
Inputs)
459 error(
" Invalid input index '%d'. There are %d possible inputs configured. ",inputidx,length(this.
Inputs));
463 if ~isempty(inputidx)
489 fprintf(2,
" NumStateDofs not set. Guess from initial value: %d\n ",this.
NumStateDofs);
518 if ~isempty(this.
B) && ~isempty(this.
inputidx)
555 t = this.
Model.scaledTimes;
557 y = zeros(size(hlp,1),length(
t));
560 y(:,idx) = this.
C.
evaluate(
t(idx),mu)*x(:,idx);
626 elseif ~isempty(this.
f)
643 if (size(mu,2) > 1) && ~isscalar(ss)
644 ss = repmat(ss,1,size(mu,2));
675 error(
" First order with AlgebraicDofs not yet implemented. ");
688 if ~isempty(this.
Params) && ~isempty(find(strcmpi(name,[this.
Params(:).Name]),1))
689 error(
" Parameter with name %s already exists. Use setParam instead. ",name);
691 p = data.ModelParam(name,
default, varargin[:]);
720 if ~ischar(paramname)
721 error(
" Parameter paramname must be a char array ");
723 pidx = find(strcmpi(paramname,[this.
Params(:).Name]),1);
736 mu = this.
Model.DefaultMu;
742 pt.addRow(
" Parameter name ",
" Value ",
" Index ");
745 pt.addRow(this.
Params(i).Name,
mu(i),i);
760 h = pm.nextPlot(sprintf(
" u%d ",i),sprintf(
" u_%d = %s ",i,func2str(ui)),...
761 " t ",sprintf(
" u_%d ",i));
762 plot(h,this.
Model.Times,ui(this.
Model.scaledTimes),
" LineWidth ",2);
787 if ~isa(model,
" models.BaseModel ")
788 error(
" The Model property has to be a child of models.BaseModel ");
807 #if 0 //mtoc++: 'set.f'
809 if ~isempty(value) && ~isa(value,
" dscomponents.ACoreFun ")
810 error(" The property '
f' has to be a class implementing dscomponents.ACoreFun ");
822 #if 0 //mtoc++: 'set.B'
824 if ~isempty(value) && ~isa(value,
" dscomponents.AInputConv ")
825 error(" The property '
B' has to be a class implementing dscomponents.AInputConv ");
834 #if 0 //mtoc++: 'set.A'
836 if ~isempty(value) && ~(isa(value,
" dscomponents.LinearCoreFun ") || isa(value,
" dscomponents.AffLinCoreFun "))
837 error(
" The property 'A' has to be a LinearCoreFun or AffLinCoreFun. ");
846 #if 0 //mtoc++: 'set.C'
849 value = dscomponents.LinearOutputConv(1);
850 warning(" An output conversion must always exist. Choosing dscomponents.LinearOutputConv(1) for simple forwarding. ");
851 elseif ~isa(value, " dscomponents.AOutputConv ")
852 error(" The property '
C' has to be a class implementing dscomponents.AOutputConv ");
861 #if 0 //mtoc++: 'set.Inputs'
864 error(" Property '
Inputs' must be a
cell array. ");
867 if ~isempty(value[n])
882 #if 0 //mtoc++: 'set.Params'
884 if ~isa(value,
" data.ModelParam ")
885 error("
Params property must be a ModelParam array. ");
894 #if 0 //mtoc++: 'set.x0'
896 this.
checkType(value,
" dscomponents.AInitialValue ");
910 #if 0 //mtoc++: 'get.ParamCount'
912 value = length(this.
Params);
919 #if 0 //mtoc++: 'get.InputCount'
921 value = length(this.
Inputs);
928 #if 0 //mtoc++: 'set.MaxTimestep'
930 if (~isscalar(value) || value <= 0) && ~isempty(value)
931 error(" Value must be a positive real scalar if not empty. ");
940 #if 0 //mtoc++: 'set.StateScaling'
943 error("
StateScaling must not be empty. (Set to 1 if not needed). ");
944 elseif ~isvector(value)
function ad_ic = getAlgebraicDofsInitialConditions()
The default is to return all zeros.
function matrix< double > x0 = getX0(rowvec< double > mu)
Gets the initial state variable at .
function J = getStateJacobian(unused1, unused2, unused3)
Params
The parameters usable for the dynamical system.
The base class for any KerMor detailed model.
function updateSparsityPattern()
function J = getStateJacobian(x, t)
Default implementation of jacobian matrix evaluation via finite differences.
dscomponents.AInputConv B
The input conversion.
function prepareSimulation(colvec< double > mu)
A method that allows parameter-dependent computations to be performed before a simulation using this ...
Model
The Model this System is attached to.
function setConfig(mu, inputidx)
Sets the dynamical system's configuration.
A MatLab cell array or matrix.
function J = getJacobian(double t, xc)
Computes the global jacobian of the current system.
Base class for any KerMor class.
function rsys = getReducedSystemInstance(models.ReducedModel rmodel)
Creates a reduced system given the current system and the reduced model.
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
The KerMor reduced model class.
virtual function x0 = evaluate(mu)
Evaluates the initial value for a given mu.
A MatLab function handle.
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
inputidx
The current inputindex of the function .
Matlab's base handle class (documentation generation substitute)
function updateDimensions()
AInitialValue: Abstract base class for dynamical systems initial values.
Basic interface for all dynamical system's core functions Inherits the AProjectable interface...
dscomponents.AInitialValue x0
Function handle to initial state evaluation.
logical HasRowHeader
Flag that determines if there is a row header for the table.
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
A variable number of input arguments.
function fx = evaluate(colvec< double > x, unused1, unused2)
mu
The current parameter for simulations, [] is none used.
InputCount
The number of inputs available.
Inputs
The system's possible input functions. A cell array of function handles, each taking a time argument ...
function dx = ODEFun(double t,colvec< double > x)
Debug variant for single evaluation. Commented in function above.
colvec StateScaling
The scaling for the state vectors.
function prepareSimulation(colvec< double > mu,integer inputidx)
function fx = evaluate(x, t)
Evaluates the f-approximation. Depending on a possible projection and the CustomProjection-property t...
Linear core function for state space models (no time or parameter)
logical TimeDependent
Flag whether the output converter actually depends on a time variable. Implemented for speed reasons ...
PrintTable: Class that allows table-like output spaced by tabs for multiple rows. ...
integer DependentParamIndices
Indices of the parameter vector that are effectively used in the system's core function.
function pidx = getParamIndexFromName(paramname)
Gets the index within the parameter vector for a given parameter name.
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
dscomponents.LinearOutputConv C
The output conversion Defaults to an LinearOutputConv instance using a 1-matrix, which just forwards ...
function checkType(obj, type)
Object typechecker.
dscomponents.ACoreFun f
The core f function from the dynamical system.
dscomponents.ACoreFun g
The system's algebraic constraints function.
ParamCount
The number of the system's parameters.
function count = cprintf(style, format, varargin)
CPRINTF displays styled formatted text in the Command Window.
function validateModel(models.BaseFullModel model)
Validates if the model to be set is a valid BaseModel at least. Extracting this function out of the s...
function y = computeOutput(matrix< double > x,colvec< double > mu)
Computes the output from a given state result vector , using the system's time and current mu (if gi...
SparsityPattern
The global sparsity pattern for the entire RHS.
function M = getMassMatrix()
For first order systems, only algebraic constraints need to be catered for.
function C = evaluate(double t,colvec< double > mu)
Evaluates the output conversion matrix. In this simple case this is just the projection matrix...
dscomponents.AMassMatrix M
The system's mass matrix.
BaseFirstOrderSystem(models.BaseFullModel model)
Creates a new base dynamical system class instance.
u
The current input function as function handle, [] if none used.
double MaxTimestep
The maximum timestep allowed for any ODE solvers.
function ModelParam p = addParam(char name, default, varargin)
Adds a parameter with the given values to the parameter collection of the current dynamical system...
Base class for all KerMor first-order dynamical systems.
Simple affine-linear core function "f" for a dynamical system.
dscomponents.LinearCoreFun A
Represents a linear or affine-linear component of the dynamical system.
Standard linear output converter.
function pt = getParamInfo(colvec< double > mu)