Skip to main content

PenWin32 (Pendulo) python API calling interface

What is it?

A python package enabling users to call a minimal set of PenWin32.dll API functions and subroutines within python scripts. For latest python version e.g. 3.10. 32 bits only.

Installation

Windows only

pip install pendulo

Requirements (32 bits)

  1. python 3.10

  2. numpy 1.21.3 (python 3.10)

  3. ganessa 2.2.9

  4. Pendulo kernel library (penwin32.dll) 2022+

  5. valid Pendulo_size and Pendulo_version license

This tool expects Picwin32.dll to be in the PATH or in one of the following folders:

                %localappdata%/Programs/Safege/Pendulo or
                %localappdata%/Programs/Suez/Pendulo or
[ C: or D: ] / 'Program Files (x86)/Safege/Pendulo_'
             + ['' or '_fr' or '_uk' or '_esp' or '_eng'] + ['' or '_ck']

With custom installations, PENDULO_DIR environment variable can be set to define the path.

Content

The package provides:
  1. pen_vers = init(debug=0) function

  2. close() function

  3. coef, name, ref_name = get_unit_info(attr) retrieves the unit coef, name and reference unit

  4. index, z, cs, head = get_node(node) returns node index (>0), elevation, demand, head at node

  5. stat = set_node_boundary_condition(node, ts_data, cond=’CS’) sets demand boundary condition at node. ts_data is a sequence of (time, value) tuples.

  6. stat = run_simulation(horizon=-1, storage_factor=-1) runs the transient simulation over the given horizon and store results every storage_factor step. Defaults to the model values.

  7. vdat, vval = ts(id_elem, typelt, attr) retrieves the result TS for element ‘id_elem’ of type ‘typelt’ and attribute ‘attr’.

Example of ‘typelt’ and ‘attr’:
  1. ‘LINK’ or ‘ARC’: ‘Q’

  2. ‘NODE’ or ‘NOEUD’: ‘P’, ‘CH’ or ‘HH’

  3. ‘TANK’ or ‘RESERVOIR’: ‘NC’ or ‘NV’, ‘VO’

  4. ‘PUMP’ or ‘POMPE’: ‘PC’, ‘VR’, ‘Q’

  5. ‘VANNE’ or ‘ROBINET’ or ‘REGULATEUR’: ‘DO’, ‘PC’, ‘Q’

  6. ‘ANB’: ‘Q’, ‘VO’, ‘NC’ or ‘NV’

Example

# -*- coding: utf-8 -*-
from logging import root
import os.path as OP
import pendulo
from ganessa.plot import pageplot
from ganessa.util import winstr, strf3
import ganessa.sim as pic


folder = OP.dirname(__file__)
# init pendulo
pendulo.init()
model = OP.join(folder, 'VIROFL_1.PEN')
# load Pendulo model
print('===\nChargement de ', model)
istat = pendulo.loadmodel(winstr(model))
if not istat:
    print(' * Erreur au chargement *')

# get unit for demand at node
cs_coef, cs_name, cs_ref = pendulo.get_unit_info('CS')
print(f'Unit CS: {cs_name} = {cs_coef} {cs_ref}')
# get demand value at a given node
node = 'PEN1'
idx, z_node, cs_node, ch_node = pendulo.get_node(node)
print(f'Demand at node {node} is: {strf3(cs_node)} {cs_name}')
# set / change demand boundary condition: sequence of (time, value) tuples
stat = pendulo.set_node_boundary_condition(node, [(0, cs_node), (0.5, 3*cs_node)])
print('Changing demand', 'OK' if stat else '*failed*')

# run simulation
print('Starting simulation ... please wait')
stat = pendulo.run_simulation(horizon=20, storage_factor=10)
print('Simulation','OK' if stat else '*failed*')
# collect results
results = []
for node in ['PEN1', '36N646', '36N495', '36N488', '36N463', '36N35']:
    t, v = pendulo.ts(winstr(node), typelt='NODE', attr='CH')
    if len(t) and len(v):
        results.append((node, t, v))
fname = OP.join(folder, 'Simulation_1.png')
pageplot(results, 'Simulation #1 - Charge aux noeuds', 2, 3, fname, inter=False, orient='h')
pendulo.close()

Metadata

Release files for pendulo 0.9.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pendulo 0.9.8
File Interpreter ABI Platform
pendulo-0.9.8-cp313-cp313-win32.whl CPython 3.13 CPython 3.13 Windows x86-32 Details

Release files / pendulo-0.9.8-cp313-cp313-win32.whl

Download URL pendulo-0.9.8-cp313-cp313-win32.whl
Size 268.6 kB
Tags CPython 3.13 Windows x86-32
SHA-256 checksum
How to use checksums
e6e521fec2c04c4036dd6df376b957b72c9dfe60d68f3e20a4c8e62163cac1f5
BLAKE2b-256 checksum
How to use checksums
8d4fd8287d26cb9b9256620d127cfa7a697dbec36ed28c172c866f270c98a247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.9.8 This release

1 release file

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page