The example input file for Problem 1, "free_falling_body.mbd," is shown again in Code 1. In this chapter we start analyzing the contents of this input file.
# free_falling_body.mbd begin: data; problem: initial value; end: data; begin: initial value; initial time: 0.; final time: 1.; time step: 1.e-3; max iterations: 10; tolerance: 1.e-6; end: initial value; begin: control data; structural nodes: 1; rigid bodies: 1; gravity; end: control data; begin: nodes; structural: 1, dynamic, null, eye, 0., 3., 0., null; end: nodes; begin: elements; body: 1, 1, 1., null, eye; gravity: 0., 0., -1., const, 9.81; end: elements;
First of all, let's focus on the structure of the input file. From Code 1 we can see that the whole input file is divided into five parts. These parts are called blocks. Basically, an input file consists of the following five blocks:
Each block starts with a begin statement and ends with an end statement.
begin: <block> ; ... end: <block>;
Each block has a different role and contains a different type of data. The role of each block is briefly described in the following.
In this block we select the problem to be solved. At present only the initial value problem is supported. The inverse dynamics problem is currently under development and is anticipated to be supported in the future.
In this block we set various conditions related to numerical computation for the problem selected in the data block. Because only the initial value problem is supported at present, the syntax of the block is as follows.
begin: initial value; ... end: initial value;
For the initial value problem, we set, for example, the following conditions.
In this block we provide mainly information that is common to the whole simulation model. We set some global parameters here. We also declare here what types of entities (nodes and elements) are used how many in the model.
In this block we define nodes. A node is an entity that owns kinematic degrees of freedom.
In this block we define elements. Elements are building blocks of a simulation model. For example, rigid bodies, joints, forces, and gravity are all elements.
- In summary, the nodes block and the elements block define a simulation model itself and the control data block provides supplemental information about the model, while numerical computation is carried out subject to the conditions provided in the data block and the <problem> block.
Now that the structure of the input file is clear, let's take a closer look at the contents of the input file (Code 1) from top to bottom.
The first row reads as follows.
This is a comment. In general, characters between the symbol "#" and the end of the line are regarded as comments and ignored by MBDyn. Another method to put comments, which is useful especially for multi-line comments, is to put them between "/*" and "*/". Comments can be put anywhere in an input file.
Next, let's look at the data block.
begin: data; problem: initial value; end: data;
Here, it is declared that the initial value problem is to be solved.
By the way, a minimal structure such as
problem: initial value;
is called a statement, where the part of "problem" is called card and the part of "initial value" is called argument. The general syntax of a statement is as follows.
<card> : <argument> ;
There is a colon ":" between the card and the argument. A statement ends with a semi-colon ";". Depending on cards, there may be no argument or multiple arguments. In case there is no argument, a colon is not needed. In case there are multiple arguments, arguments are separated by a comma ",". An input file is fundamentally a list of statements.
Next is the <problem> block.
begin: initial value; initial time: 0.; final time: 1.; time step: 1.e-3; max iterations: 10; tolerance: 1.e-6; end: initial value;
In this block, conditions related to the numerical integration to solve the initial value problem are set. In this example, it is set that the numerical integration is to be carried out from time 0 to 1 with a time step 1e-3. Conditions such as "time step," "max iterations," and "tolerance" are usually determined considering the trade off between computational cost and accuracy. There are many other conditions that can be set. Refer to the official input manual for more information.
By the way, it is seen in the above section of code that there are cases where a number has a decimal point and where a number does not have a decimal point. This is because MBDyn distinguishes integer numbers and real numbers rather strictly. As a general rule, put a decimal point to a number that should be handled as a real number and don't put a decimal point to a number that should be handled as an integer. This is especially critical when mathematical operations are involved. For example, 3./5. is processed as 0.6, while 3/5 is processed as 0.
Let's move on to the control data block.
begin: control data; structural nodes: 1; rigid bodies: 1; gravity; end: control data;
In this block, the types and the numbers of nodes and elements that are to be defined in the nodes block and elements block are declared in advance. In this example, it is declared that one "structural node", one "rigid body," and the gravity are to be defined.
So far, the contents of the data block, the <problem> block, and the control data block of the input file for Problem 1, "free_falling_body.mbd," have been analyzed. The remaining nodes block and elements block are treated in the next chapter.