Python wrapper for the CANDE FEA culvert analysis engine
Project description
cande-wrapper
Python wrapper for the CANDE (Culvert ANalysis and DEsign) finite element engine.
The CANDE-2025 Fortran source is compiled via f2py into a native Python extension module, allowing direct calls from Python without subprocess overhead or DLL wrappers.
Prerequisites
| Dependency | Version | Purpose |
|---|---|---|
| Python | >= 3.10 | Runtime |
| gfortran | any recent | Compiles the CANDE Fortran engine |
| NumPy | >= 1.26 | f2py extension building and runtime |
| Meson | >= 1.1 | Build system |
| Ninja | any recent | Build backend for Meson |
Installing gfortran on Windows
The easiest way is via MSYS2:
# In MSYS2 terminal
pacman -S mingw-w64-x86_64-gcc-fortran
# Add to PATH (PowerShell)
$env:PATH += ";C:\msys64\mingw64\bin"
Or install via conda:
conda install -c conda-forge gfortran
Installing build tools
pip install meson-python meson ninja numpy
Installation
From the project root:
pip install -e ".[dev]"
This compiles the Fortran engine via f2py and installs the Python package in editable mode. The [dev] extra includes pytest and jupyter for testing and notebooks.
If the build fails, see Troubleshooting below.
Quick Start
from cande_wrapper import CandeEngine
engine = CandeEngine(work_dir="path/to/my/models")
result = engine.run("EX1") # reads EX1.cid, writes EX1.out
print(result.output_text)
CANDE Input Files
CANDE reads .cid input files (CANDE Input Data). These are fixed-format text files with sections:
- A-1: Master control line (analysis/design mode, solution level, title)
- A-2: Pipe type and element counts
- B-*: Pipe material properties
- C-*: Mesh, node, and element definitions
- D-*: Soil properties and load steps
- STOP: End-of-problem marker
Multiple problems can be run back-to-back in a single .cid file, each terminated by STOP.
An example input file is included at tests/example_data/MGK-IO.cid.
Output Files
After running engine.run("prefix"), these files are created in the working directory:
| File | Description |
|---|---|
prefix.out |
Main analysis output report |
prefix.log |
Engine log messages |
prefix.ctc |
Table of contents for the output |
prefix_MeshGeom.xml |
Mesh geometry (for visualization) |
prefix_MeshResults.xml |
Mesh results (for visualization) |
prefix_BeamResults.xml |
Beam element results |
prefix_PLOT1.dat |
Plot data file 1 |
prefix_PLOT2.dat |
Plot data file 2 |
The CandeResult object returned by engine.run() gives convenient access to the main output files:
result = engine.run("EX1")
print(result.output_file) # Path to EX1.out
print(result.log_file) # Path to EX1.log
print(result.output_text) # Full contents of EX1.out
Testing
pytest -v # unit tests (no build required)
pytest -m integration -v # integration tests (requires build)
pytest -m "" -v # all tests
Troubleshooting
gfortran: command not found
gfortran is not on your PATH. Verify with gfortran --version. On Windows, ensure the MSYS2/MinGW or conda bin directory is in your PATH.
Linker errors about missing symbols
The meson.build file lists Engine source files explicitly. If you see unresolved symbols like plasti_ or prhero_, the corresponding .f file needs to be added to the engine_sources list in meson.build.
ImportError: CANDE Fortran extension not found
The package was imported but the compiled extension (_cande.pyd / _cande.so) was not found. Rebuild with:
pip install -e . --no-build-isolation
Large memory usage
The CANDE engine statically allocates ~320 MB for the stiffness matrix (REAL*8 A(20000,2000) in system.fi). This is normal for FEA solvers and is mapped as virtual memory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cande_wrapper-0.1.13.tar.gz.
File metadata
- Download URL: cande_wrapper-0.1.13.tar.gz
- Upload date:
- Size: 383.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac728e7d8f7549227b54603f04c566538e71d6053b3f44f230c273cedf2bd5ef
|
|
| MD5 |
646909a899a6c06cd664d29a8a493062
|
|
| BLAKE2b-256 |
c2135647274acbda7016acbba3c493eb91c0f37023c1cab5f9f5b041b03363b4
|
File details
Details for the file cande_wrapper-0.1.13-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db6558eecd6e5007138fe5e91177b0220cee7a6a9080bc9913d2e8c1b9679eed
|
|
| MD5 |
6ef9e8d1c993a1e6ca578e7ca539a960
|
|
| BLAKE2b-256 |
45f5312be0031bbbe7d1c171d913093074b755c6241eb9b8832308005dcbe9b8
|
File details
Details for the file cande_wrapper-0.1.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2757f02bd86195951ba7c2f462433173c002d529e29b7ec740d140d9544a23d2
|
|
| MD5 |
8cb8f142694c0dfefd0f14085745d85c
|
|
| BLAKE2b-256 |
6fc4ae1019c3d90eec196c7a1ab2cc07541dec1a4c6f86bc96af9a0c67f6944c
|
File details
Details for the file cande_wrapper-0.1.13-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdf1fffc8e42fe4bcc9dc76156b93646ebcd06e275473f0c89d2749ac0e0e7d4
|
|
| MD5 |
58216c99fc11254c2ff64424cf1c41c3
|
|
| BLAKE2b-256 |
9be5f21ce8234ae48f0bb97e79d961ca3a1ac0bd56e4b5d12e81921c6c1e7005
|
File details
Details for the file cande_wrapper-0.1.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8b924e84457fbc0d3c7b24f6921b8c008597861437c0b64f627d20567b74411
|
|
| MD5 |
5426e31abb29ab7cd21d38a87097e479
|
|
| BLAKE2b-256 |
5f9e657bf20aa24bd3dca37658e0f65eb42cea1e3fb026828cf68f0391ee369b
|
File details
Details for the file cande_wrapper-0.1.13-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd173f49527102715119c35c4c599d1581508d9a161489517c9c3b97377f0954
|
|
| MD5 |
0f177cae34ac55d7c828a37916a56318
|
|
| BLAKE2b-256 |
fc4507e87be61ba7adb4b6caa4bd06182250483c8f0d6c2c272779577466d5fe
|
File details
Details for the file cande_wrapper-0.1.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
716d9e60efe77224ca0580737fd3ff66ccd1f680c89d2a7266c38183233d4ce6
|
|
| MD5 |
8271082bf0d740e5c1446bc42660c81e
|
|
| BLAKE2b-256 |
9096d37c1b3c828d7a03df353b928134969d884a326975cfe9a2c38127125f7e
|
File details
Details for the file cande_wrapper-0.1.13-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b44847a32e87e7233bc0061586f4f901fab5b5df87cf957d710cb418c3c4490
|
|
| MD5 |
1e6ca0cfe31cc9c8c15b5c752fddf9ad
|
|
| BLAKE2b-256 |
30ca56604721a6d31898fa67f1b77fc1eb13543bc016709848fd871f8681d311
|
File details
Details for the file cande_wrapper-0.1.13-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.1.13-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c7b33e2871c0ed83cc0c269ede41c75ec5a853593a2da09ee3d22b1a72c24a2
|
|
| MD5 |
271e2a19c12a8ecb03f928c88f25f2ae
|
|
| BLAKE2b-256 |
8581edb888abdd4a45c7d778763f378a05e85d9456fbe1c2ced1aff0114b89eb
|