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.
Installation
Install from PyPI (includes pre-built wheels for Windows and Linux):
pip install cande-wrapper
For development (requires gfortran):
pip install -e ".[dev]"
Build prerequisites (development only)
| 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
Via MSYS2:
# In MSYS2 terminal
pacman -S mingw-w64-x86_64-gcc-fortran
# Add to PATH (PowerShell)
$env:PATH += ";C:\msys64\mingw64\bin"
Or via conda:
conda install -c conda-forge gfortran
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)
Vehicle definitions
Standard AASHTO design vehicles are available for live-load analysis:
from cande_wrapper import Vehicle
hs20 = Vehicle.hs20() # AASHTO HS-20 (72 kip)
hs25 = Vehicle.hs25() # AASHTO HS-25 (90 kip)
tandem = Vehicle.tandem() # AASHTO design tandem (50 kip)
cooper = Vehicle.cooper_e80() # Cooper E-80 railroad (160 kip)
Custom vehicles can be defined with arbitrary axle configurations:
from cande_wrapper import Vehicle, WheelFootprint, Axle
truck = Vehicle(
name="Custom Truck",
footprint=WheelFootprint(length=12.0, width=24.0, spacing=84.0),
axles=[
Axle(weight=12000, spacing=0),
Axle(weight=40000, spacing=180),
Axle(weight=40000, spacing=54),
],
)
print(f"{truck.name}: {truck.total_weight/1000:.0f} kip")
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.2.0rc1.tar.gz.
File metadata
- Download URL: cande_wrapper-0.2.0rc1.tar.gz
- Upload date:
- Size: 400.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3f566358a64bac094b8e0d776c4e0e9a91bd65180d64498d49542774fd44671
|
|
| MD5 |
673a34307c67c70dbe9353ac71a94d15
|
|
| BLAKE2b-256 |
87c97a88b1586e1b3059833c1fdc5dc74ff64ff08353ab9150fdf6c773185a9e
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
7943fa2bd2765a7d68d40fa3f1b33d9658f562263a5c7351b6009ea89d32edcb
|
|
| MD5 |
3380a61e43c088c700e62d5d2cd4a536
|
|
| BLAKE2b-256 |
f1991fa34239394fd5cf1396db4ad296fd86d1c6b07a9465b41d46a17577063a
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
673caae10248eee5d8f90949f3815dcbd82eb1e731c4175ce99fb672e1eb2393
|
|
| MD5 |
8930a5b406fa8eeafa64a3ef11e90ef5
|
|
| BLAKE2b-256 |
e79e534dc10e1a995459a258ed143cf263066d436c1651059cf8a97deb9a5ce0
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
f9aca4755fe20e9be8a6806bbeec8270a4afa7bb576da613791b56f6ac850268
|
|
| MD5 |
7b8a2d5ef08f52c36d53e4cd2bd9bf25
|
|
| BLAKE2b-256 |
105383deab5af794bc20963fc79755b6d5e30028cfe426c753b2870487e3056f
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
93a9babb9d70ca17ad1260d031443fd2eb712a818e864f015953d903427229ce
|
|
| MD5 |
dc6e16d3c0122f0f84b80982c3e1fa46
|
|
| BLAKE2b-256 |
6b78797f671917ee1fcb9589b7c7a929595e18dc600e7fc50c48726f53e7097d
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
d0dfd983e56d38146544aff2a432b4e455ebc38f7ec88956e21999317a30f8d5
|
|
| MD5 |
0b2fa222e3e64b5c72592b9f51558952
|
|
| BLAKE2b-256 |
1251a7be2474223dc9f10dae41a04b8b28be21b98db7fbdf6c44336b07908abd
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
6d34bc1384fc29bb89c6724bc6aee214c259ee0779e83a6a5c36335b3c003502
|
|
| MD5 |
f63b2bcbcd5737f74113e7ad2845579a
|
|
| BLAKE2b-256 |
01ef68d189e1f496808525fdbf7edca6536ef465aec75502203f099055874105
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
07d65ee13f43b746fe5cea280de178a1790513aea27db0d64c3443c781468672
|
|
| MD5 |
6b2433aabe5728594b376c0c48132e19
|
|
| BLAKE2b-256 |
87916e2044daaf65e35a89799e2cfbb418152b36a1c4ab13fe624588d66fa155
|
File details
Details for the file cande_wrapper-0.2.0rc1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cande_wrapper-0.2.0rc1-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 |
f3888270f5066cb56e2405234199440acfe57279d2a310963e0fe39ff1c6a284
|
|
| MD5 |
c0b8fb354aec27641df63fa5f709c106
|
|
| BLAKE2b-256 |
f4b97f84d4bd8aa961b9951c6ca69eeba4b5a3edfc66cbf10598ead7da9540be
|