97 name = sprintf(
" FEM Muscle model %s ",
class(conf));
98 this =
this@models.BaseFullModel(name);
100 this.
SaveTag= sprintf(
" musclemodel_%s ",
class(conf));
113 s = solvers.MLode15i;
129 s = spacereduction.PODReducer;
130 s.IncludeInitialSpace=
true;
135 conf.configureModel(
this);
141 conf.configureModelFinal;
167 xargs = [
" NF ",nf,
" DF ",df];
169 this.
plot(t,y,xargs[:]);
174 this.
Config.prepareSimulation(mu, inputidx);
177 fprintf(
" Finished after %gs (fevals:%d, Jacobians: %d)\n ",time,f.nfevals,f.nJevals);
197 t.addRow(
" \rho_0 ",
" c_{10} [MPa] ",
" c_{01} [MPa] ",
" b_1 [MPa] ",
" d_1 [-] ",
" P_{max} [MPa] ",
" \lambda_f^{opt} ");
198 t.addRow(this.
MuscleDensity, mu(9),mu(10),mu(5),mu(6),mu(13),mu(14));
214 this.
Config.setForceLengthFun(f);
219 fl = f.ForceLengthFun(lambda);
220 h = pm.nextPlot(
" force_length_plain ",
" Direct force-length curve of muscle/sarcomere ",...
221 sprintf(
" \\lambda [-], fl_p1=%g ",mu(14)),...
222 " force-length relation [-] ");
227 fl_eff = (mu(13)./lambda) .*
fl;
229 aniso_passive_muscle = f.AnisoPassiveMuscle(lambda);
233 pos = find(aniso_passive_muscle > max(fl_eff)*1.4,1,
" first ");
235 lambda = lambda(1:pos);
236 fl_eff = fl_eff(1:pos);
237 aniso_passive_muscle = aniso_passive_muscle(1:pos);
240 h = pm.nextPlot(
" force_length_eff ",...
241 " Effective force-length curve of muscle material ",...
242 " \lambda [-] ",
" pressure [MPa] ");
243 plot(h,lambda,fl_eff,
" r ",lambda,aniso_passive_muscle,
" g ",lambda,fl_eff+aniso_passive_muscle,
" b ");
244 legend(h,
" Active ",
" Passive ",
" Total ",
" Location ",
" NorthWest ");
271 aniso_passive_tendon = f.AnisoPassiveTendon(lambda);
272 h = pm.nextPlot(
" force_length_tendon ",...
273 " Effective force-length curve of tendon material (=passive) ",...
274 " \lambda [-] ",
" pressure [MPa] ");
275 plot(h,lambda,aniso_passive_tendon,
" g ");
284 [LAM,TMR] = meshgrid(lambda,tmr);
285 passive = repmat(aniso_passive_muscle,length(tmr),1) ...
286 + tmrlog^
t*(aniso_passive_tendon-aniso_passive_muscle);
289 FL = (1-tmr)^
t*fl_eff;
292 h = pm.nextPlot(
" force_length_muscle_tendon ",...
293 " Effective force-length curve between muscle/tendon material ",...
294 " \lambda [-] ",
" muscle/tendon ratio [m=0,t=1] ");
295 surfc(LAM,TMR,passive+FL,
" Parent ",h,
" EdgeColor ",
" interp ");
296 zlabel(
" pressure [MPa] ");
297 zlim([0, 3*max(fl_eff(:))]);
318 warning(
" Using muscle parameters only (ignoring tendon) ");
320 [lambda, alpha] = meshgrid(.02:.02:1.5,0:.01:1);
322 fl = f.ForceLengthFun(lambda/mu(14));
323 active = mu(13)./lambda.*
fl.*alpha;
325 passive = max(0,(b1./lambda.^2).*(lambda.^d1-1));
327 h = pm.nextPlot(
" aniso_pressure ",sprintf(
" Pressure in fibre direction for model %s ",this.
Name),
" Stretch \lambda ",
" Activation \alpha ");
328 surf(h,lambda,alpha,active+passive,
" EdgeColor ",
" k ",
" FaceColor ",
" interp ");
339 h = pm.nextPlot(
" activation ",sprintf(
" Activation curve for model %s ",this.
Name),
" time [ms] ",
" alpha [-] ");
340 plot(h,this.
Times,f.alpha(
this.scaledTimes),
" r ");
349 if ~isempty(varargin) && isa(varargin[1],
" PlotManager ")
350 varargin = [[
" PM "] varargin];
355 varargin(end+1:end+2) = [
" NF ",nf];
357 varargin(end+1:end+2) = [
" Velo ",
true];
360 old = this.
Plotter.DefaultArgs;
368 this.
Config.plotGeometryInfo(varargin[:]);
374 num_bc = length(sys.idx_u_bc_glob)+length(sys.idx_expl_v_bc_glob);
375 residuals_dirichlet = zeros(num_bc,length(t));
376 residuals_neumann = zeros(length(sys.idx_neumann_bc_glob),length(t));
378 dy = sys.f.evaluate(uvw(:,
k),
t(
k));
379 if ~isempty(residuals_neumann)
380 residuals_neumann(:,
k) = dy(sys.idx_neumann_bc_dof);
382 residuals_dirichlet(:,
k) = sys.f.LastBCResiduals;
391 geo = this.
Config.FEM.Geometry;
392 idxXYZ =
false(3,geo.NumNodes);
393 for k=1:length(faces)
394 idxXYZ(dim,geo.Elements(elem,geo.MasterFaces(faces(
k),:))) =
true;
396 idx = find(idxXYZ(:));
417 geo = this.
Config.FEM.Geometry;
419 idx_face(dim,geo.Elements(elem,geo.MasterFaces(face,:))) =
true;
442 geo = this.
Config.FEM.Geometry;
444 idx_face(dim,geo.Elements(elem,geo.MasterFaces(face,:))) =
true;
447 fidx = fidx + geo.NumNodes*3;
469 if ~isa(value,
" models.muscle.AMuscleConfig ")
470 error(
" Config must be a models.muscle.AMuscleConfig instance ");
480 mc.FEM.GaussPointRule= value;
481 mc.PressureFEM.GaussPointRule= value;
492 s.prepareSimulation(mu,in);
510 #if 0 //mtoc++: 'get.Geo'
511 function value =
Geo() {
512 value = this.
Config.Geometry;
524 m = models.muscle.Model(models.muscle.examples.Debug);
525 mu = m.getRandomParam;
526 [
t,y] = m.simulate(mu);
527 m.System.UseDirectMassInversion=
true;
528 [
t,y] = m.simulate(mu);
531 m = models.muscle.Model(models.muscle.examples.Debug(2));
532 [
t,y] = m.simulate(mu);
533 m.System.UseDirectMassInversion=
true;
534 [
t,y] = m.simulate(mu);
537 m = models.muscle.Model(models.muscle.examples.Debug(3));
538 [
t,y] = m.simulate(mu);
539 m.System.UseDirectMassInversion=
true;
540 [
t,y] = m.simulate(mu);
541 m.System.UseDirectMassInversion=
false;
545 [
t,y] = m.simulate(mu);
546 m.System.UseDirectMassInversion=
true;
547 [
t,y] = m.simulate(mu);
549 ME.getReport(
" extended ");
556 m = models.muscle.Model(models.muscle.examples.Debug(2));
561 res = f.test_Jacobian;
562 m.setGaussIntegrationRule(4);
563 res = res && f.test_Jacobian;
564 m.setGaussIntegrationRule(5);
565 res = res && f.test_Jacobian;
578 if ~isa(
this,
" models.muscle.Model ")
580 this = models.muscle.Model;
583 this =
loadobj@models.BaseFullModel(
this, sobj);
585 this =
loadobj@models.BaseFullModel(
this);
char Name
The name of the Model.
bool_u_bc_nodes
% Position dirichlet fields Boundary conditions: 3 times numnodes logical matrix telling which degree...
MuscleFibreSystem: The global dynamical system used within the MuscleFibreModel.
static function res = test_ModelVersions()
function setConfig(value)
The base class for any KerMor detailed model.
double dt
The desired time-stepsize for simulations.
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
function varargout = plotGeometrySetup(varargin)
Times
Evaluation points of the model.
function prepareSimulation(colvec< double > mu)
A method that allows parameter-dependent computations to be performed before a simulation using this ...
function plotAnisotropicPressure(colvec< double > mu)
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
function idx = getPositionDirichletBCFaceIdx(integer elem,integer face,rowvec< integer > dim)
Returns the positions of dofs of a specified face within the boundary conditions residual vector...
function setGaussIntegrationRule(value)
Sets the gauss integration rule for the model.
int RandSeed
Seed that can be used by random number generator instances in order to enable result reproduction...
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
function varargout = plot(varargin)
function idx = getVelocityDirichletBCFaceIdx(integer elem,integer face,rowvec< integer > dim)
Returns the positions of dofs of a specified face within the boundary conditions residual vector...
A variable number of input arguments.
function plotForceLengthCurve(colvec< double > mu, pm)
function [ residuals_dirichlet , residuals_neumann ] = getResidualForces(double t, uvw)
Plotter
The plotter class for visualization.
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
mu
The current parameter for simulations, [] is none used.
integer DefaultInput
The default input to use if none is given.
rowvec< integer > TrainingParams
The indices of the model parameters to use for training data generation.
function [ double t , colvec< double > x , time , cache ] = computeTrajectory(colvec< double > mu,integer inputidx)
Allows to also call prepareSimulation for any quantities set by the AMuscleConfig class...
double T
The final timestep up to which to simulate.
data.ModelData Data
The full model's data container. Defaults to an empty container.
static function this = loadobj()
spacereduction.BaseSpaceReducer SpaceReducer
The reduction algorithm for subspaces.
PrintTable: Class that allows table-like output spaced by tabs for multiple rows. ...
idx_v_bc_glob
This set comprises both the explicit velocity conditions and the implicit zero velocity conditions th...
bool_expl_v_bc_nodes
% Velocity dirichlet fields This set comprises the explicitly/directly set velocity boundary conditio...
ModelData(varargin)
Creates a new container for large full model data.
function double t = getConfigTable(colvec< double > mu)
colvec< double > DefaultMu
The default parameter value if none is given.
dscomponents.ACoreFun f
The core f function from the dynamical system.
function x_xdot_c0 = getX0(colvec< double > mu)
Compiles the global x0 vector of the global dof vector.
function colvec< integer > idx = getFaceDofsGlobal(integer elem,rowvec< integer > faces,rowvec< integer > dim)
Returns the indices in the global uvw vector (including dirichlet values) of the given faces in the g...
System(models.BaseFullModel model)
Call superclass constructor.
Global configuration class for all KerMor run-time settings.
function initDefaultParameter()
Reads the default values of the System's ModelParam list and initializes the BaseModel.DefaultMu with it.
static function res = test_JacobianApproxGaussRules()
Tests the precision of the analytical jacobian computation using different gauss integration rules...
function [ double t , matrix< double > y ] = simulateAndPlot(withResForce, varargin)
static function KerMor theinstance = App()
The singleton KerMor instance.
double MaxTimestep
The maximum timestep allowed for any ODE solvers.
function prepareSimulation(colvec< double > mu,integer inputidx)
Check for viscosity setting.
function plotActivation()
function plotGeometryInfo(varargin)
function [ rowvec< double > t , matrix< double > y , double sec , x ] = simulate(colvec< double > mu,integer inputidx)
Simulates the system and produces the system's output.
char SaveTag
A custom tag that can be used as a prefix to files for corresponding model identification.
A variable number of output arguments.
Model: Model for a FEM-discretized muscle model.