Skip to content

Commit b6f4024

Browse files
JacobAdamsenJacob Hilmar Adamsen
andauthored
Excluded "A Study of Studies" tutorial and moved its content (#42)
Co-authored-by: Jacob Hilmar Adamsen <jha@anybodytech.com>
1 parent e181529 commit b6f4024

26 files changed

+603
-285
lines changed

A_Getting_started/index.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Getting Started - First steps
22

3-
The objective of this tutorial is to demonstrate some of the features of
4-
the AnyBody Modeling System using an existing model.
3+
The objective of this tutorial is to demonstrate some of the features of the
4+
AnyBody Modeling System using an existing model. The reader will get an
5+
impression of the system’s capabilities and see a complex musculoskeletal model
6+
in action.
57

6-
The reader will get an impression of the system’s capabilities and see a
7-
complex musculoskeletal model in action.
8+
Finally, the last lesson will explain some general concepts about simulations
9+
in AnyBody Modeling System.
810

911
::::{if-builder:: html
1012
```{rubric} Tutorial content
@@ -18,4 +20,5 @@ Introduction <intro>
1820
lesson1
1921
lesson2
2022
lesson3
23+
lesson4
2124
```

A_Getting_started/intro.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ the model view window
2121
This tutorial relies heavily on using the AnyBody Managed Model Repository (AMMR).
2222
Follow the steps below to unpack a local version of the AMMR.
2323

24-
# Setup the AMMR
24+
## Setup the AMMR
2525

2626
Before you continue, you must unpack the entire repository and save it on your
2727
hard disk. To get a copy of the AMMR, press the Demo tab in the AnyBody
@@ -34,7 +34,7 @@ your documents folder by default. It is good practice to create a second local
3434
copy of the AMMR so that you do not overwrite the original AMMR folder by
3535
accident.
3636

37-
# AMMR structure
37+
## AMMR structure
3838

3939
Open a file manager and navigate to the directory where you unpacked the
4040
repository. You should see a folder structure that includes the following

A_Getting_started/lesson4.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
::: {rst-class} break
2+
:::
3+
4+
# Lesson 4: Understanding Simulations
5+
6+
Now that you have a basic understanding of the AnyBody Modeling System and have
7+
had some hands-on experience, this lesson will give you a deeper understanding
8+
of what studies and operations are - the core components of all simulations in
9+
AnyBody.
10+
11+
In the AnyBody Modeling System, all types of simulations, whether they are pure
12+
mechanical system analysis, musculoskeletal analysis or design analysis, are
13+
carried out by objects that are referred to as “studies”. Studies have
14+
operations that can be executed to perform the analysis.
15+
16+
Meaning, studies and operations are the mechanisms used to specify tasks to
17+
be performed on the model. Think of a study as a collector that brings together
18+
a model definition, the operations that execute the model, and the results to be
19+
analyzed afterwards. Meaning, operations are the tasks performed on the model.
20+
They can be executed from the AnyBody interface, generating and storing output
21+
in the study based on the function of the specific operation.
22+
23+
## Why Do We Need Studies?
24+
25+
You might wonder why we need studies. After all, couldn’t you just load a model
26+
and have operations readily available in the AnyBody interface? The answer lies
27+
in the flexibility that studies offer.
28+
29+
Studies are defined as special classes, allowing you to have multiple studies in
30+
the same model. As objects in the model, you can have as many studies as you
31+
need (or as many as your computer can handle), and they don’t necessarily have
32+
to operate on the same model definition, even if they share elements.
33+
34+
For instance, you might want to perform different operations on the same model,
35+
or perform the same operation on nearly identical models, and then compare the
36+
results. With two studies, you can do this within a single AnyBody model.
37+
38+
## The Hierarchy of Study Classes
39+
40+
Studies are derived from a base class called `AnyStudy`, and the operations found
41+
within studies are also defined as classes, all derived from the base class
42+
`AnyOperation`.
43+
44+
Here's a look at the hierarchy of study classes in AnyBody:
45+
46+
47+
- `AnyStudy` (Base class for all studies)
48+
49+
- `AnyTimeStudy` (Base class for time variation studies)
50+
51+
- `AnyKinStudy`
52+
53+
- `AnyMechStudy`
54+
- `AnyBodyStudy`
55+
- `AnyBodyCalibrationStudy`
56+
57+
- `AnyDesStudy` (design variable studies, see *a separate tutorial*)
58+
59+
60+
## Mechanical Studies
61+
62+
Mechanical studies, derived from `AnyMechStudyBase`, are quite similar, but they
63+
contain different sets of available operations. The base class is empty, with
64+
`AnyKinStudy` extending it with functionality for kinematic analysis.
65+
`AnyMechStudy` further extends this with kinetic (dynamic) analysis of basic
66+
mechanical systems.
67+
68+
`AnyBodyStudy` is the most frequently used study by AnyBody users, as it extends
69+
the kinematic analysis functions with operations for kinetic (dynamic) analysis
70+
of musculoskeletal systems, which is the core functionality of the AnyBody
71+
Modeling System. It also contains almost all of the operations found in other
72+
mechanical studies. `AnyBodyCalibrationStudy` provides additional functionality
73+
to adjust/calibrate the musculoskeletal models systematically.
74+
75+
## Understanding the Structure of a Study
76+
77+
A study in AnyBody is essentially a folder that contains specifications. These
78+
specifications are placed between a pair of braces and become part of the study.
79+
A study has predefined properties that you can set, must set, or cannot modify.
80+
81+
When you create a new model using `File` -> `New from Template...`, the system
82+
automatically inserts an AnyBodyStudy in the main file. It looks like this:
83+
84+
```AnyScriptDoc
85+
// The study: Operations to be performed on the model
86+
AnyBodyStudy MyStudy = {
87+
AnyFolder &Model = .MyModel;
88+
Gravity = {0.0, -9.81, 0.0};
89+
};
90+
```
91+
92+
This study contains all the necessary elements. The first word after
93+
`AnyBodyStudy` defines the name of the study, which in this case is "MyStudy". The
94+
last line `Gravity = {0.0, -9.81, 0.0};` assigns a value to the Gravity
95+
variable, which specifies the gravitational acceleration vector affecting the
96+
model.
97+
98+
An `AnyBodyStudy` has many more predefined properties that you can modify. You
99+
can view these properties using the Model Tree View, which is attached to the
100+
left of the Main Frame. Double-clicking any object in the Model Tree will show
101+
you properties of the objects in the Object Description dialog box.
102+
103+
Most of the properties deal with solution methods, tolerances, and other
104+
advanced user features. However, some properties are essential for all users:
105+
106+
* `tStart`: The time at which the study begins. Usually, this is zero.
107+
* `tEnd`: The time at which the study ends. This often needs to be set by the user.
108+
* `nStep`: Specifies how many steps the system should use to go from tStart to tEnd.
109+
110+
Let's take a closer look at the first line of the study:
111+
112+
```AnyScriptDoc
113+
AnyFolder &Model = .MyModel;
114+
```
115+
116+
:::{note}
117+
:class: margin
118+
You can choose to point to some subfolders of `MyModel` instead of the entire
119+
model. This means the study would work on just a subset of the model. For
120+
example, you might want to compare two nearly identical models. In this case,
121+
you can put all common parts in one folder and the distinctive parts in separate
122+
folders. Then, you can create two studies that reference the common part and
123+
their respective distinctive parts.
124+
:::
125+
126+
Here, "AnyFolder" is a type definition. Unlike the predefined properties
127+
discussed above, this line introduces a new property to the study. This is a
128+
key aspect of studies: you can add almost anything to a study, and the study
129+
doesn't need to know its type in advance.
130+
131+
This line defines a variable called "Model" and assigns it to `.MyModel`. In
132+
this case, `MyModel` is the folder that contains the entire model. The prefix `.`
133+
before `MyModel` indicates that it's one level up from where it's referenced.
134+
135+
By assigning `MyModel` to the Model variable, the entire model comes under the
136+
influence of the study. The `&` before "Model" means that Model doesn't get
137+
replicated inside the study. Instead, it's a pointer to `MyModel`. If you're
138+
familiar with C, C++, or Java programming, you'll recognize this as the concept
139+
of pointers. If not, think of a pointer as a reference to something defined
140+
elsewhere. When you access it, you're actually interacting with what it points
141+
to.
142+
143+
## The Standard Operations in a Study
144+
145+
When you create an `AnyBodyStudy`, it automatically includes three standard
146+
operations in the study tree. These operations represent different actions you
147+
can perform on the model elements that the study points to:
148+
149+
* `InitialConditions`: This operation reads the values of all drivers
150+
included in the study, and sets the model to match these drivers at the
151+
start time (tStart). Meaning it puts the model in the position it has at
152+
`time=tStart`. The model is first initialized into the positions from
153+
load time, and the kinematics is then solved in a few steps. This is
154+
especially helpful for inspecting the specified initial positions if you're
155+
having issues with the initial configuration of the mechanism. The
156+
`InitialConditions` can only run successfully if all joints and drivers are
157+
fully defined.
158+
159+
Note, that the the model's positions after running `InitialConditions`
160+
is different from the position after just loading the model, called
161+
the load-time position.
162+
163+
* `Kinematics`: This operation performs a kinematic analysis, which is a
164+
simulation of the model's movement without calculating any forces. This means
165+
you can run a Kinematics operation as soon as you've uniquely defined the
166+
movement and the model is kinematically determinate. You don't need any
167+
muscles in the model for this operation.
168+
169+
The data you can extract from the Kinematics study includes positions,
170+
velocities, and accelerations.
171+
172+
* `InverseDynamics`: This operation simulates the forces involved in the given
173+
movement or posture, along with anything that can be derived from them. The
174+
InverseDynamics operation uses the Kinematics operation as a subroutine, so it
175+
requires a correctly defined movement or posture, as well as the necessary
176+
muscles or motors to drive the model.
177+
This is also known as kinetic or dynamic analysis.
178+
179+
:::{admonition} Note on InverseDynamics
180+
:class: note
181+
You might think that calculating forces in a rigid body mechanical system is
182+
straightforward. After all, isn’t it just about setting up equilibrium equations
183+
and solving them? Well, it’s a bit more complex than that, especially when it
184+
comes to biomechanics.
185+
186+
In biomechanics, we often deal with statically indeterminate systems. This means
187+
we don’t have enough equilibrium equations to resolve the forces in the system.
188+
Plus, we have to consider that muscles can only pull, not push. This adds
189+
another layer of complexity to the problem.
190+
191+
The `AnyBodyStudy` class is designed to handle these complexities. It uses
192+
algorithms that are tailored for musculoskeletal systems.
193+
194+
There’s also the `AnyMechStudy` class, which contains a simpler InverseDynamics
195+
operation. This operation doesn’t deal with the complexities of musculoskeletal
196+
systems. Instead, it solves the basic inverse dynamics problem for a simple
197+
mechanical system, finding the reaction forces that balance the system.
198+
:::
199+
200+
When you execute each of these operations, they compile their output in the
201+
Output section under the study tree. This allows you to easily access and
202+
analyze the results of each operation.
203+
-4 Bytes
Binary file not shown.

A_Getting_started_anyscript/Downloads/demo.lesson5.any

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,18 @@ Main = {
109109

110110
AnyFolder Drivers = {
111111
//---------------------------------
112-
AnyKinEqSimpleDriver ShoulderMotion = {
112+
AnyKinDriver ShoulderMotion = {
113113
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
114-
DriverPos = {-100*pi/180};
115-
DriverVel = {30*pi/180};
114+
DriverPos0 = {-100*pi/180};
115+
DriverVel0 = {30*pi/180};
116116
}; // Shoulder driver
117117
//---------------------------------
118-
AnyKinEqSimpleDriver ElbowMotion = {
118+
AnyKinDriver ElbowMotion = {
119119
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
120-
DriverPos = {90*pi/180};
121-
DriverVel = {45*pi/180};
120+
DriverPos0 = {90*pi/180};
121+
DriverVel0 = {45*pi/180};
122122
}; // Elbow driver
123123
}; // Driver folder
124-
125124
}; // MyModel
126125

127126
// The study: Operations to be performed on the model

A_Getting_started_anyscript/Downloads/demo.lesson6.any

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,20 @@ Main = {
112112

113113
AnyFolder Drivers = {
114114
//---------------------------------
115-
116-
AnyKinEqSimpleDriver ShoulderMotion = {
115+
AnyKinDriver ShoulderMotion = {
117116
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
118-
DriverPos = {-100*pi/180};
119-
DriverVel = {30*pi/180};
117+
DriverPos0 = {-100*pi/180};
118+
DriverVel0 = {30*pi/180};
120119
Reaction.Type = {Off};
121120
}; // Shoulder driver
122-
123121
//---------------------------------
124-
AnyKinEqSimpleDriver ElbowMotion = {
122+
AnyKinDriver ElbowMotion = {
125123
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
126-
DriverPos = {90*pi/180};
127-
DriverVel = {45*pi/180};
124+
DriverPos0 = {90*pi/180};
125+
DriverVel0 = {45*pi/180};
128126
Reaction.Type = {Off};
129127
}; // Elbow driver
130-
}; // Driver folder
128+
}; // Driver folder
131129

132130
AnyFolder Muscles = {
133131
// Simple muscle model with constant strength = 400 Newton

A_Getting_started_anyscript/Snippets/lesson4/snip.NewModel.main-1.any

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,16 @@ Main = {
110110

111111
§AnyFolder Drivers = {
112112
//---------------------------------
113-
AnyKinEqSimpleDriver ShoulderMotion = {
113+
AnyKinDriver ShoulderMotion = {
114114
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
115-
DriverPos = {-100*pi/180};
116-
DriverVel = {30*pi/180};
115+
DriverPos0 = {-100*pi/180};
116+
DriverVel0 = {30*pi/180};
117117
}; // Shoulder driver
118118
//---------------------------------
119-
AnyKinEqSimpleDriver ElbowMotion = {
119+
AnyKinDriver ElbowMotion = {
120120
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
121-
DriverPos = {90*pi/180};
122-
DriverVel = {45*pi/180};
121+
DriverPos0 = {90*pi/180};
122+
DriverVel0 = {45*pi/180};
123123
}; // Elbow driver
124124
}; // Driver folder§
125125
//# END SNIPPET 1

A_Getting_started_anyscript/Snippets/lesson4/snip.NewModel.main-2.any

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,20 @@ Main = {
109109

110110
AnyFolder Drivers = {
111111
//---------------------------------
112-
AnyKinEqSimpleDriver ShoulderMotion = {
112+
AnyKinDriver ShoulderMotion = {
113113
//# BEGIN SNIPPET 1
114114
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
115115
//# END SNIPPET 1
116-
DriverPos = {-100*pi/180};
117-
DriverVel = {30*pi/180};
116+
DriverPos0 = {-100*pi/180};
117+
DriverVel0 = {30*pi/180};
118118
}; // Shoulder driver
119119
//---------------------------------
120-
AnyKinEqSimpleDriver ElbowMotion = {
120+
AnyKinDriver ElbowMotion = {
121121
//# BEGIN SNIPPET 2
122122
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
123123
//# END SNIPPET 2
124-
DriverPos = {90*pi/180};
125-
DriverVel = {45*pi/180};
124+
DriverPos0 = {90*pi/180};
125+
DriverVel0 = {45*pi/180};
126126
}; // Elbow driver
127127
}; // Driver folder
128128

A_Getting_started_anyscript/Snippets/lesson5/snip.NewModel.main-1.any

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ Main = {
109109

110110
AnyFolder Drivers = {
111111
//---------------------------------
112-
AnyKinEqSimpleDriver ShoulderMotion = {
112+
AnyKinDriver ShoulderMotion = {
113113
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
114-
DriverPos = {-100*pi/180};
115-
DriverVel = {30*pi/180};
114+
DriverPos0 = {-100*pi/180};
115+
DriverVel0 = {30*pi/180};
116116
}; // Shoulder driver
117117
//---------------------------------
118-
AnyKinEqSimpleDriver ElbowMotion = {
118+
AnyKinDriver ElbowMotion = {
119119
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
120-
DriverPos = {90*pi/180};
121-
DriverVel = {45*pi/180};
120+
DriverPos0 = {90*pi/180};
121+
DriverVel0 = {45*pi/180};
122122
}; // Elbow driver
123123
//# BEGIN SNIPPET 1
124124
}; // Driver folder

A_Getting_started_anyscript/Snippets/lesson5/snip.NewModel.main-2.any

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ Main = {
109109

110110
AnyFolder Drivers = {
111111
//---------------------------------
112-
AnyKinEqSimpleDriver ShoulderMotion = {
112+
AnyKinDriver ShoulderMotion = {
113113
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
114-
DriverPos = {-100*pi/180};
115-
DriverVel = {30*pi/180};
114+
DriverPos0 = {-100*pi/180};
115+
DriverVel0 = {30*pi/180};
116116
}; // Shoulder driver
117117
//---------------------------------
118-
AnyKinEqSimpleDriver ElbowMotion = {
118+
AnyKinDriver ElbowMotion = {
119119
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
120-
DriverPos = {90*pi/180};
121-
DriverVel = {45*pi/180};
120+
DriverPos0 = {90*pi/180};
121+
DriverVel0 = {45*pi/180};
122122
}; // Elbow driver
123123
}; // Driver folder
124124
//# BEGIN SNIPPET 1

0 commit comments

Comments
 (0)