Skip to main content

Python wrapper for the CANDE FEA culvert analysis engine

Project description

cande-wrapper

Pipeline Coverage PyPI - Python Version ![PyPI - License](https://img.shields.io/pypi/l/cande-wrapper) [![PyPI Downloads](https://static.pepy.tech/badge/cande-wrapper/month)](https://pepy.tech/projects/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.

Source · PyPI


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cande_wrapper-0.2.1.tar.gz (402.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cande_wrapper-0.2.1-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

cande_wrapper-0.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cande_wrapper-0.2.1-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

cande_wrapper-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cande_wrapper-0.2.1-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

cande_wrapper-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cande_wrapper-0.2.1-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

cande_wrapper-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file cande_wrapper-0.2.1.tar.gz.

File metadata

  • Download URL: cande_wrapper-0.2.1.tar.gz
  • Upload date:
  • Size: 402.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for cande_wrapper-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f1dddab672aab2f9cd8bbd7f2e854d3853ea74953bf1e1a7ad9652ff6babb4d0
MD5 7e0fa75dedea74786b7a3c3bc67eda30
BLAKE2b-256 9de2f673e1df1321827d7d0951500199309bdf3b7b86fc7283a3d6520f40f470

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a48716028929ffe546ea5e1737eb79cfc2766d9f1f256785622749dd6c75957f
MD5 e36c8ad8bb41bae1323cbdee4c36c75f
BLAKE2b-256 4acbbbc2e4a97e6d467b3d164a9c28478265466e78c48ac09cca6d92d4c115c1

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 083da47191ba329685367fd79aa95340f7ab1d3dac1e71ed2149bfb424d6ac1c
MD5 ffdf72bb60f5e0312a7c946a6f0bb522
BLAKE2b-256 34f6c63ee6eb2e655073b52002e66df6a1eeaff40097cee1cb9a835b8184341e

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 19020402a98bcffb0e7933516756995d10fafa9eee0d0c78e1aa785d54078bb7
MD5 14c913cdde931ac306ff61eb2de4a2c4
BLAKE2b-256 cb951dd91c0603875946b11f1054e1ac67141ca13b3ca888dc6c8026623452b1

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d0f278430d2d5e3b00a4af87400d92290ff5042c661a67c9c1abb290b3c4ba0f
MD5 bb7141d3612ae314fcc1c87250b8495b
BLAKE2b-256 6be46a588ae6a1e9f39da0618a4409c9e8e2fd5788d7c9c6c159e08811d8d54c

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 49931bb322ebf4e4febdf991fb1c07a03f68cb84e9bd56f9203b773c5c74afc8
MD5 4247e263cfd71de03cd502984dd21d0d
BLAKE2b-256 22025d3f0ceebfbb0e5f912287bf26c8cca522478b7c1e4319a2942cd6546b4e

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2433970bd64057a1dcf7f0b94b3a598eff24784df776b77e383808fb83a88df3
MD5 1c9c44621e560e99d1a54a13639f5b05
BLAKE2b-256 d97ebcf254d4c818b4740ec607393cdbf99885dd2313a26c3cbd72f116b6ba71

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 34c8fc4469263a25d90c176be545bfb2c2a3f2b24a8b8112edd87c00b28de47b
MD5 514ea6d0d89a74759943c03d23e2ce27
BLAKE2b-256 86efffc5c2acb3579cca2d887f4061747cca8ea54401467639e1946ef3c575de

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 1c8468f943e147b02763305bc28623d4c37d5d25115fe394d78143d6910b8890
MD5 6cd065124795201add745af7c5c85cbb
BLAKE2b-256 85dafa49934206b35b2148c954f0039a07f6f7a06d7bd7281827d8cbaa5d48c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page