Wiki

Clone wiki

PPME-Lang / PPML Front-end

HOME > FRONT-END

PPML Front-end


PPML Program Structure

The overall structure of a program (former client) written in the PPML-IDE is built up from a module containing a sequence of phases.

The module can declare external variables (via the external keyword) in order to specify required variables which should be passed in from outside the module. For instance, problem-specific variables such as a reaction rate or constant can be made available in the simulation.

Each phase has a simple producer-consumer-like interface, specifying input and output variables of the phase. Variables that are required in the phase's body and should be passed in from another phase have to be specified in an in declaration. Likewise, "produced" variables that should be made available to subsequent phases have to be declared in an out declaration.

The following two code snippets illustrate the use of phase interfaces. In the left snippet, the phase initialize takes no inputs (indicated by << ... >>) and makes a particle list available for subsequent phases. In the right snippet, the solve phase requires a particle list as input which needs to have the two scalar fields U and V defined.

ppml-phase_out.png ppml-phase_in.png

In the current implementation (v0.1.0 - 2015-08-28) phases are just inlined in the code generation step. Thus, the order of phases is important. The idea is to make the phase model more flexible in future versions of PPML-IDE and allow for arbitrary phase structuring and dependencies.


Basic PPML Types

PPML offers small set of available types. Besides the boolean type for logical values and a string type for character sequences there are two more primitive types for numerical values, the integer type and the real type for decimal numbers. Additionally, there are two basic container types, a vector and a matrix, which can have an arbitrary type as component type. The figure below shoes the hierarchy of basic types in available in PPML-IDE.

ppml-type_hierarchy.png

In addition to the basic types defined in ppml.expressions there are domain-specific types defined in ppml.core. These are shown in the figure below. In the current implementation (v0.1.0 - 2015-08-28) a particle list is a vector of particles: vector<particle>.

ppml-core_types_hierarchy.png


General Language Structures

PPML-IDE offers a basic set of general programming language structures, e.g., arithmetical and logical expression. Moreover, ppml.statements provides a base set of statements, for instance, if and for-each statements, variable declarations, and a generic print statement.


Domain-specific Language Structures

Besides the general programming language structures described in the section above, PPML-IDE contains a set of domain-specific language structures tailored towards the programming model of particle-mesh methods. A structural overview of the domain-specific expressions can be seen in the figure below.

ppml-core_expressions_hierarchy.png

In the following, some language features should be explained in more detail.

Mathematical Expressions (Power, Differentials)

In the current implementation (v0.1.0 - 2015-08-28) the available differential operators are hard-coded into the language implementation. In order to use the Laplacian operator in your program, just type laplace and the IDE will add a differential expression with the Laplacian. Likewise, type jacobian for a differential expression using the Jacobian operator.

Furthermore, PPML-IDE lets you write power expressions by typing ** directly after an expression. You can then put in the exponent.

Initialize Statements

Since some programming concepts in particle-mesh methods require a more complex initialization, PPML-IDE offers initialize statements for both declarations and referenced variables. The initialize statement can be accessed via typing init and using the auto-complete function (usually Ctrl+Space). In the simplest case, the programmer can advice the system to declare a variable and at the same time initialize it, as shown in the snippet below. In this case, the topology is declared with the name topo and initialized with "bcdef".

ppml-initialize_declaration.png

Similarly, an already declared variable can be initialized. In both cases, more complex initialization code can be provided via the keyword with which enables an initialization body. The following example shows how two fields U and V are initialized on the list of particles. Moreover, the particles are distributed via the *distribute statement (type distribute).

ppml-initialize_reference_with_distribute.png

Create Neighborlist and Exchange Statements

You can advice PPM to create a neighborlist for some particle list through the create neighborlist statement which can be accessed via auto-completion (Ctrl+Space) after typing create.

ppml-create_nlist.png

Similarly, the exchange of data can be triggered through the exchange statement. Auto-complete will offer you a choice of available exchange methods, as shown in the figure below. The exchange statement can be accessed by typing exchange.

ppml-exchange_ghost.png

Timeloop, ODE, and RHS

The timeloop statement marks a simulation loop in an PPML program. You can add a new timeloop statement to your simulation by typing timeloop. Within the loop's body, the particle-mesh simulation happens. For instance, you can add an ODE system to solve by typing ode and specifying the desired solver method, e.g., "rk4". A differential right-hand side equation can be added within an ODE environment by typing rhs.

The following figure shows the timeloop of the Gray-Scott reaction-diffusion system. The example also shows the Laplacian operator and the use of the power expression.

ppml-grayscott_timeloop.png

Inline-Code Statement

PPML-IDE allows you to step into an "expert mode" by writing code in the target language directly. Code written in an inline code statement will be directly copied into the generated program at the specific location. The inline code statement can be accessed by typing inline. The following graphic shows some inlined Fortran code.

ppml-inline_code_stmt.png


PPME@bitbucket | PPME-Lang@bitbucket

Updated