Python interface for retrieving results of Pendulo water hammer simulation
Project description
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)
python 3.10
numpy 1.21.3 (python 3.10)
Pendulo kernel library (penwin32.dll) 2022+
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:
pen_vers = init(debug=0) function
close() function
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’:
‘LINK’ or ‘ARC’: ‘Q’
‘NODE’ or ‘NOEUD’: ‘P’, ‘CH’ or ‘HH’
‘TANK’ or ‘RESERVOIR’: ‘NC’ or ‘NV’, ‘VO’
‘PUMP’ or ‘POMPE’: ‘PC’, ‘VR’, ‘Q’
‘VANNE’ or ‘ROBINET’ or ‘REGULATEUR’: ‘DO’, ‘PC’, ‘Q’
‘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()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pendulo-0.9.6-cp310-cp310-win32.whl
.
File metadata
- Download URL: pendulo-0.9.6-cp310-cp310-win32.whl
- Upload date:
- Size: 226.5 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e05262e9ab51ed891ae5b2412e6de88b9d9a660510ba219286eb1338fa8d044f |
|
MD5 | 2ceb057f640f32d6f9f34951265c2f78 |
|
BLAKE2b-256 | 90bb97d0074afa6a4fb4193f2b551c21dcf465f1c19d3f7a6326a123caa985d0 |
File details
Details for the file pendulo-0.9.6-cp39-cp39-win32.whl
.
File metadata
- Download URL: pendulo-0.9.6-cp39-cp39-win32.whl
- Upload date:
- Size: 226.4 kB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 416c1b6435460e267dffaa5285d6356380dd1389260a3e5f50dfb3f4e4342a15 |
|
MD5 | a3f6d5f0ef86af8ac4499db7f082a28f |
|
BLAKE2b-256 | eb42d34ee5a4f49de13f1c66df8ca5b90f971da537041d5a2879981b210762be |