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.0rc1.tar.gz (400.8 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.0rc1-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

cande_wrapper-0.2.0rc1-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.0rc1-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

cande_wrapper-0.2.0rc1-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.0rc1-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

cande_wrapper-0.2.0rc1-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.0rc1-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

cande_wrapper-0.2.0rc1-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.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

Hashes for cande_wrapper-0.2.0rc1.tar.gz
Algorithm Hash digest
SHA256 c3f566358a64bac094b8e0d776c4e0e9a91bd65180d64498d49542774fd44671
MD5 673a34307c67c70dbe9353ac71a94d15
BLAKE2b-256 87c97a88b1586e1b3059833c1fdc5dc74ff64ff08353ab9150fdf6c773185a9e

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7943fa2bd2765a7d68d40fa3f1b33d9658f562263a5c7351b6009ea89d32edcb
MD5 3380a61e43c088c700e62d5d2cd4a536
BLAKE2b-256 f1991fa34239394fd5cf1396db4ad296fd86d1c6b07a9465b41d46a17577063a

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 673caae10248eee5d8f90949f3815dcbd82eb1e731c4175ce99fb672e1eb2393
MD5 8930a5b406fa8eeafa64a3ef11e90ef5
BLAKE2b-256 e79e534dc10e1a995459a258ed143cf263066d436c1651059cf8a97deb9a5ce0

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f9aca4755fe20e9be8a6806bbeec8270a4afa7bb576da613791b56f6ac850268
MD5 7b8a2d5ef08f52c36d53e4cd2bd9bf25
BLAKE2b-256 105383deab5af794bc20963fc79755b6d5e30028cfe426c753b2870487e3056f

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 93a9babb9d70ca17ad1260d031443fd2eb712a818e864f015953d903427229ce
MD5 dc6e16d3c0122f0f84b80982c3e1fa46
BLAKE2b-256 6b78797f671917ee1fcb9589b7c7a929595e18dc600e7fc50c48726f53e7097d

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d0dfd983e56d38146544aff2a432b4e455ebc38f7ec88956e21999317a30f8d5
MD5 0b2fa222e3e64b5c72592b9f51558952
BLAKE2b-256 1251a7be2474223dc9f10dae41a04b8b28be21b98db7fbdf6c44336b07908abd

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6d34bc1384fc29bb89c6724bc6aee214c259ee0779e83a6a5c36335b3c003502
MD5 f63b2bcbcd5737f74113e7ad2845579a
BLAKE2b-256 01ef68d189e1f496808525fdbf7edca6536ef465aec75502203f099055874105

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 07d65ee13f43b746fe5cea280de178a1790513aea27db0d64c3443c781468672
MD5 6b2433aabe5728594b376c0c48132e19
BLAKE2b-256 87916e2044daaf65e35a89799e2cfbb418152b36a1c4ab13fe624588d66fa155

See more details on using hashes here.

File details

Details for the file cande_wrapper-0.2.0rc1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cande_wrapper-0.2.0rc1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 f3888270f5066cb56e2405234199440acfe57279d2a310963e0fe39ff1c6a284
MD5 c0b8fb354aec27641df63fa5f709c106
BLAKE2b-256 f4b97f84d4bd8aa961b9951c6ca69eeba4b5a3edfc66cbf10598ead7da9540be

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