The entire engine operation cycle is simulated on the basis of one- and zero-dimensional thermo- and gas-dynamical models.
All these models are based on the model of gaseous working fluid. Its properties adopted here are properties of 2-component mixture. In case of engine simulation these 2 components should be: fresh air and pure burnt gases of specified fuel, with specified air-to-fuel ratio (AFR). Molar weights of these 2 components may differ, and their heat capacities can be approximated with polynomials.
The core of modeling program is the set of models of components and connectors.
Components used in this version are Atmosphere, Vessel, Duct, Cylinder and Crankcase. Component Duct represents a one-dimensional profiled pipe. One-dimensional unsteady conservation laws are used to describe motion of the gaseous mixture along the Duct:

For the simulation of flows in pipelines the concept of local flow restriction is used. Local flow restriction (local restriction -- LR) is an abstraction
that serves as a replacement to a real element of the piping -- location at which some sudden flow redistribution takes place and pure 1D formulation
cannot be used to "close" the problem.
All connectors (assembly elements used to interconnect components) use similar concept.
The simplest possible type of LR is the one on which the flow takes place without splitting. This type of connector, named Restriction, is used to model this case. Only the next three types of models for such connector are imaginable:
When using the above listed LR concept, we are facing certain simplification that, however, helps to describe real (dissipative!) flows still in 1D formulation. These models require some additional information to close the 1D flow problem -- they need some empirical data on the properties of actual flow on connector.
What is follows is a short theory on empirical relations needed for and used by Restriction.
Click here for more detailed description of underlying theory.
![]()

Fig. 1. Main program window with project 2-stroke-opposed loaded.
If the project shown on Fig. 1 doesn't seem to be loaded, click on button
Fig. 2. Dialog box for choosing the project to open.
Choose 2-stroke-opposed and click OK. The project will be [hopefully] loaded and shown now; it must be ready to begin simulation of such an engine. But now it is right time to explore structure of engine assembly and the properties of its modules: components and connectors. The details of modules' internal data will be revealed in Modules Reference.
Modules can be added to the assembly. By clicking on button
on the toolbar or choosing Dialog->Components menu item we'll get a palette with available Components (see Fig. 3); similarly a Connectors palette (Fig. 4) can be invoked with
or
Dialogs->Connectors command of the main menu. Both palettes are used as a source for dragging new modules of both kinds onto the assembly field view.
Fig. 3. Components palette.
Fig. 4. Connectors palette.
Modules can be moved within the assembly field. Right-click the module image with the mouse (or left-click it, holding the [Shift] key pressed) to make the module image movable. Drop the module onto the assembly field again, but please be informed that modules can not be put: (1) onto and too close to another module; (2) outside of the limiting rectangle; (3) underneath of either of palettes; (4) outside of the visible part of the assembly field view (if the user wishes to cancel dragging a module either within an assembly field or from one of "palettes", right-clicking the mouse can help).
Now we go to the actions we do with the loaded project. If we are sure that the changes we have made during the editing session are correct, we may save our project. Pressing
button or choosing Project->Save menu command does this. If we are to initiate (fork) a new project from the current, we can Save it As.. (Project->Save as). The program will ask for the name of
this new project -- that will be the name of project directory under .\prj\ (see. Fig. 5).

Fig. 5. Dialog that gets new project name while "Saving as..".
An alternative for creation the new project is to point to another project to use it as prototype (creation of blank project is not supported now!). To create project this way, click on
Fig. 6. Dialog box to get name for the prototype and for the project to create.
Running simulation is done by clickinghpl1ds [-v] [-p] [-t] 2-stroke-opposed
where -v (or --verbose), -p, ... etc. are command line switches (brackets: [..] denote that they are optional). Switches can be learned by running hpl1ds without arguments.
For this particular case (shown on Fig. 7) the computed indicated parameters are being written by solver to console at each engine cycle. Solver (when invoked with -v option) produces verbose messages (mainly at start up, not seen here). It also reports the time elapsed -- since -t option presents. Elapsed time here (on Fig. 7) is for AMD Sempron 3200+ running at 1.94 GHz. Solver also prompts user for a keystroke to terminate solver's console after the successful simulation, when run with -p (or --prompt) option (in this example -- after 40 cycles of 2-stroke engine).

Fig. 7. Console window of the solver.
Abnormal termination of running solver is done by clickingGeneral indications on number of time steps, etc., are adjusted via General dialog box for each project. In our case this dialog looks like on Fig. 8. This dialog appears on choosing Dialogs->General menu item, or on hitting [Shift+G] shortcut key combination, or by clicking on the assembly field.

Fig. 8. General dialog.
Pressing button "Run simulation" will cause saving all unsaved project data and running the solver. There is only one file being written on disk while doing "Save" operation -- the file .\prj\[project-name]\input. In our case [project-name] is 2-stroke-opposed.
# hpl1d.098 input file #######
#
# project: "2-stroke-opposed"
#
##############################
#=== section GENERAL
numstep = 57600 # number of steps
deltaT = 0 # step in time [sec]
deltaPhi = 0.25 # step in crank angle [deg.]
flag_t_phi = 2 # deltaT - 1; deltaPhi - 2 [-]
rpm = 6000 # engine speed [rpm]
flag_prstep = 0 # print each flag_prstep-th step
stroke = 2 # 2 or 4-stroke engine
Section GENERAL describes main features of every simulation. The example above shows that (flag_t_phi = 2) the stepping will be governed by step in [crank] angle, not by step in time. Its value is 1/4 or 0.25 of a degree (deltaPhi = 0.25). Value of time step will not be used in this case so it can be of any value (in particular, zero: deltaT = 0.).
Angular stepping generally means that some cylinder is present in assembly, i. e. some piston engine is simulated. In this case the engine speed must be given -- here rpm = 6000 (rpm - revolutions per minute). Type of engine cycle is given by stroke = 2 (obvious). If the user wants to model exactly 40 engine cycles, solver must do modeling over numstep = 40×360×(stroke/2) / 0.25 = 57600 steps. Variable flag_prstep specifies if step numbers are to be printed out by solver; value flag_prstep = 0 makes solver not to print step count at all,
flag_prstep = 100 -- that only every 100-th step should be reported (CPU load due to this output is diminished this way).
Section ASSEMBLY stores only 2 pairs of coordinates for the limiting rectangle for actual workspace on assembly field (in pixels). This rectangle is used solely by the GUI, it can be virtually unlimited, and it affects also assembly window scrolling ranges. It, however, limits the area in which modules can be placed.
#=== section ASSEMBLY
rect_asm = 90,60,770,520 # ...limiting rectangle [pix.]
Coordinates of this limiting rectangle can be re-set by "Assembly" dialog in GUI:

Fig. 9. Assembly dialog.
After ASSEMBLY section there is a large MODULES section in file .\prj\[project-name]\input. Modules are described in detail in Modules Reference. Here we'd draw the user's attention to setting parameters of output data streams (pre-processing) and visualizing and interpreting the simulation results (post-processing). Three "data channels" can be used to output results for engine simulation test case. SCREEN data channel (see SCREEN section in .\prj\2-stroke-opposed\input file) is written to file .\prj\[project-name]\screen by solver program. It has binary format (for compactness) and can be imaged by means of GUI and exported as text file, or saved as bitmap (BMP) file. Data stored in .\prj\screen is nothing but records of parameter values taken by virtual probes each placed within either component or connector. This set of probes and their properties can be edited easily using a dialog box that appears after choosing Dialog->Screen menu command (the same does a keyboard shortcut [Shift+S]).
Fig. 10. Dialog for editing SCREEN settings.
As it is seen, up to 8 probes can be used in this version.
Fig. 11. "Playing" the SCREEN record.
This record (Screen) can be "scanned": user can read parameter value moving vertical scan bar along time axis using arrow keys, with [Shift] key helping to do big jumps and [Ctrl] key for very big jumps. Keys [PgUp] (or ['arrow-up']) and [PgDown] (or ['arrow-down']) serve to change the parameter curve to scan.
Here is a list of commands to control Screen window, each one corresponds to the button on a toolbar (Fig. 11), from left to right:
Open another screen [O], Save screen as.. [B], Save screen as text.. [T], Close this window [Q], Scan data [S], go to Next parameter [PgUp], go to Prev. parameter [PgDown], Move to left [[Ctrl+]'arrow left'], Move to right [[Ctrl+]'arrow right'], go to Previous frame [P] or ['arrow down'], go to Next frame [N or 'arrow up'], go to First frame [F or Home], go to Last frame [L or End], Take snapshot [H] and save it to BMP file.

Fig. 12. "Scanning" the SCREEN record.
The graph has a legend (see Fig. 11) showing parameter names and colors of curves. Right-licking some of 5×4 grid cells will either relocate this legend or hide it (or show it again). Note that clicking the region with horizontal labels at the bottom of the graph changes mode of output of these labels. By default, labels show time steps, but when changed, these labels show either modeled time (in seconds) or the basic crank angle. Crank angle is measured from 0 degrees at time = 0 and wraps around each 360o or 720o, depending on the engine type (2- or 4-stroke) given in GENERAL section of file .\prj\[project-name]\input (and in General dialog in GUI).TRACK data channel (see TRACK section in e.g. .\prj\2-stroke-opposed\input file) is (optionally) being written to file .\prj\[project-name]\track by the solver. This [binary] file holds nothing but animation of parameters written each intervalth step along the sequence of chosen modules-components. The dialog box that sets this data channel is invoked by Dialog->Track menu command or using [Shift+T] shortcut.

Fig. 13. Dialog for editing TRACK settings.
Clicking on
Fig. 14. "Playing" the TRACK record.
TRACK can also be "scanned" (see Fig. 15). Navigation while scanning here is similar to that of SCREEN "player" dialog. TRACK can be read from or written to a file on hard disk as well.Below is a list of commands that can control TRACK window, each one corresponds to the button on a toolbar (Fig. 14), from left to right:
Open another track [O], Save track as.. [B], Save track frame as text.. [T], Close this window [Q], Scan data [S], go to Next parameter [PgUp], go to Prev. parameter [PgDown], Move left [[Ctrl + ]'arrow left'], Move right [[Ctrl + ]'arrow right'], make updating Slower [L], make updating Faster [F], Rewind [W] record, Pause/Resume playback [P/R], Take snapshot [H] and save it to BMP file.

Fig. 15. "Scanning" the TRACK record.
Some of the above listed commands are supported by mouse. Left- (or middle-) click on a graph area changes to scan mode, right-click changes back. When entering scan mode, vertical scan bar position is determined by position of the mouse pointer. Clicking by the left mouse button re-positions this scan bar, and a mouse wheel helps much to change between graphs (in scan mode).The next (and the last) channel of data output -- INDICATOR. It is being written by solver to standard output and thus to console. On Fig. 16. Indicator dialog box is shown. It is invoked from the main menu by the command Dialog->Indicator or using [Shift+I] shortcut.

Fig. 16. Dialog for editing INDICATOR settings.
As it can be seen from Fig. 16., the user can switch on/off certain indicated parameters. Parameters are being printed out for each cylinder separately. Now it will become much more clear what does each parameter of INDICATOR mean. We can take data sample from Fig. 7:
----- INDICATOR output for 40th engine cycle: -----
N_i = 3.0114 kW
H = 87.574 J
L = 30.114 J
eta_i = 0.3439
m0_fresh = 0.030582 g
G_cyl = 14.8524 kg/hour
eta_V = 0.6098
phi = 1.3490
-----
where eta_V is charging efficiency and phi is inverse value of trapping efficiency. Let us check these figures using some input data from files input and thermo:
----- file "thermo" -----
lambda = 0.95 # Excess air factor
lo = 14.7764 # Stoichiometric ratio
Hu_m = 2727957 J/kg # Mixture strength
R_air = R_g1 = 288.23 J/(kg*K) # Gas constant of air
----- file "input", GENERAL section -----
rpm = 6000 rev/min # Engine speed
stroke = 2
----- file "input", data for cylinder[0] -----
D = 32 mm # Cylinder bore
r = 13 mm (s = 2 × r = 26 mm)
opposed_piston = 1 # An opposed-piston engine!)
x_z = 0.98
-----
So:
effective mass flow rate (after accounting for scavenging losses)
G_cyl_eff = G_cyl / phi = 14.8524 / 1.3490 = 11.0099 kg/h.
trapped mass of air (per one 2-stroke cycle):
m0_fresh = (G_cyl_eff / 3600) / (rpm / (30 × stroke)
= 3.0583e-05 kg = 0.0030583 g, right.
atmospheric air density:
rho_a = | as in atmosphere[11] | = p_a / (R_air * T_a)
= 101325 / (288.23 × 293.15) = 1.19919 kg/m3.
number of pistons per cylinder
i = (opposed_piston + 1) = 2.
displaced volume:
V_h = i × M_PI × D × D × s / 4 = 2 × 3.1416 × 0.032 × 0.032 × 0.026 / 4 =
= 0.00004182 m3.
charging efficiency:
eta_V = m0_fresh / (rho_a × Vh) = 3.0583e-5 / (1.19919 × 0.00004182) = 0.6098, right.
masses of fuel and mixture per cycle:
AFR = alpha × lo = 0.95 × 14.7764 = 14.0379 kg.air/kg.fuel
m0_fuel = m0_fresh / AFR = 3.0583e-5 / 14.0379 = 2.1786e-6 kg.
m0_m = m0_fresh + m0_fuel = 3.0583e-5 + 2.1786e-06 = 3.2762-5 kg.
heat released in a single cycle:
H = Hu_m × m0_m × x_z = 2727957 × 3.2762-5 × 0.98 = 87.574 J, right.
indicated efficiency (mixture losses [if present] are NOT accounted for):
eta_i = L / H = 30.114 / 87.574 = 0.3439, right.
indicated power output:
Ni = L × f = L × (rpm / (30 × stroke)) = L × (rpm / 60) = 30.114 × 6000 / 60 = 3011.4 W = 3.0114 kW, right.
fuel consumption:
G_fuel = m0_fuel × f = 2.1786e-6 × 100 = 0.00021786 kg/s =
0.784296 kg/h.
In the paragraphs below, some more advanced topics are covered; Modules Reference deals with explanations of initial data sets (TODO: and their textual presentation in file input!), Program Interface describes how the whole package is organized and some settings, Tools Reference can be used as set of mini-manuals for Tools (programmed models that are outside of the solver) and Examples briefly describes a set of example projects in different areas, the projects that can be used as a robust starting points for the user's own simulation projects.
Finally, it should be noted that either clicking on
button, or choosing Help->Contents or pressing [F1] brings up a HTML browser with starting page of this HTML help system.
And choosing Help->About gives you the following window, which also might be useful:

Fig. 17. "About" window.
The most valuable information in this paragraph is the graphical representation of data flow and invocation of different program components of the package. As the latter gets mature, the number of programs and links between its cpmponents increases. Here is the schematic view of basic interactions.

Fig. 18. Scheme of program components and data flow.
This is the real interface worth to be learned. Graphical user interface -- that goes below -- is pretty easy to learn and use.Menu Options contains commands that call dialog boxes that allow editing different settings. Currently there are only 2 groups of settings available under Options: Solver and Environment. Environment options (see Fig. 19) affect the assembly field: its background color and color of links drawn between modules, width of scroll bars and steps used in scrolling and the limiting rectangle re-sizing oprrations and finally the language of messages output by the GUI.

Fig. 19. Dialog box for environment options.
Solver options can be set up by the user, bearing in mind that solver is a standalone program and that (1) it can be run with different levels of priority and (2) it can get some command-line arguments.
Fig. 20. Dialog box for editing solver options.
| bin\ | binaries, program components: executable files and DLLs |
| class\ | files of Java byte-codes (*.class files for Screen and Track utilities) |
| data\ | data files with thermodynamics and characteristics files |
| doc\ | documentation: HTML and image files |
| prj\ | projects directory |
| tmp\ | directory for temporary files |
| utils\ | useful utilities |
Below are command (or batch) files placed in the package's root directory. These batch files are for running almost any program component and can also serve as examples of their usage.
| hpl1dw.bat | runs package's GUI |
| hpl1ds.bat | runs solver for specified project |
| thermo.bat | runs Thermo tool (thermo.exe + thermo.dll) |
| data.bat | runs Data tool (data.exe + data.dll) |
| porting.bat | runs Porting tool (porting.exe + porting.dll) |
| massive.bat | runs Massive tool (massive.exe + massive.dll) |
| optimum.bat | runs Optimum tool (optimum.exe + optimum.dll) |
| screen.bat | starts Screen utility written in Java (Java RTE required!) |
| track.bat | starts Track utility written in Java (Java RTE required!) |
| hpl1dstub.bat | runs hpl1dstub.exe -- a solver replacement (for testing) |
And here are few text files:
| license.txt | text of the license agreement |
| readme.txt | Windows (®) version of README file |
| changes.txt | text file with changes logged |
| todo.txt | file with planned changes |
| bugs.txt | list of known bugs |
| bin\hpl1dw.exe | graphical user interface (GUI) |
| bin\hpl1ds.exe | solver executable (console program) |
| bin\thermo.dll | dynamic link library (DLL) for tool Thermo |
| bin\thermo.exe | console interface to Thermo DLL (simply a launcher) |
| bin\data.dll | dynamic link library: tool Data |
| bin\data.exe | console program: launcher of Data tool's DLL |
| bin\porting.exe | console program: back-end of tool Porting |
| bin\porting.dll | GUI to porting.exe |
| bin\massive.exe | console program: back-end of tool Massive |
| bin\massive.dll | GUI to massive.exe |
| bin\optimum.exe | console program: back-end of tool Optimum |
| bin\optimum.dll | GUI to optimum.exe |
| bin\hpl1dstub.exe | can be used in place of solver to setup/test/debug massive/optimizing simulations |