Overview

In this section, we will go over the main PhysioBlocks principles needed to write Blocks.

We will first learn about the Block and BlockDescription objects and their roles. We will then present the main Expressions that a Block object defines. Finally, we will go through the main differences between Blocks and ModelComponents

Block vs BlockDescription

Block and BlockDescription are two different PhysioBlocks objects. The combination of the two allows to use blocks in nets.

The Block are simple objects, they allow to compute quantities. They :

  1. Declare the Quantities they need to perform computations.

  2. Declare the functions to compute the Fluxes, Internal Equations and Saved Quantities from those quantities.

The BlockDescription are generic objects that provide the interface between a block and the net. They:

  1. Hold a reference to a specific Block instance.

  2. Hold the global name in the net for every parameter local name in the block.

  3. Hold the flux descriptions and match them with a global node in the net.

  4. Extend the block definitions holding model component descriptions.

Note

You will only have to write Block implementations, the BlockDescription are generic and already implemented in PhysioBlocks. When using the block in a net, it will be associated with a BlockDescription.

Block Definition

Any Block implementation define functions to compute:

  • Fluxes: terms summed with other fluxes of the same type at the node of the net. They are always expressed toward the outlet of the block. They are always discretized with a mid-point time scheme to ensure stability and consistency in the coupling between blocks.

  • Internal Equations: (optional) Equations concatenated to the global system. They are expressed in a residual form.

  • Saved Quantities: (Optional) Additional quantities computation to output in a result file along with the variables. They are computed once at each time step.

  • Fluxes and internal equations partial derivatives along every possible variable.

If we take a closer look at this last point, it means that you should define partial derivatives along:

  • DOFs quantities of the block

  • internal variables quantities of the block

  • any other term that could be a variable in the global system (ie. potential DOFs and internal variables of other blocks)

Note

Before launching a simulation, PhysioBlocks will build the global system based on the layout of the net and its boundary conditions. Every expressions you define will not necessarily be used in the system.

However, block implementations you write should be exhaustive to obtain modular blocks.

ModelComponents and ModelComponentDescription

ModelComponent and ModelComponentDescription objects are Block and BlockDescription base definitions. Everything that we say here about blocks is also true for model components, except:

Note

Everything done with model components sub-models can easily be done directly with block internal equations. However, we define model components for modularity purposes. It allows to re-use internal equations with different blocks.

Since the ModelComponent definition are exactly the same as Block definitions minus the flux definition, we will not detail them in the next part. However, you can find some examples in the PhysioBlocks package physioblocks/library/model_components module.

In the next part, we will see how to write a Block implementation along with an example.