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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

cande_wrapper-0.2.0-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.0.tar.gz.

File metadata

  • Download URL: cande_wrapper-0.2.0.tar.gz
  • Upload date:
  • Size: 402.0 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.0.tar.gz
Algorithm Hash digest
SHA256 a6dffa65b014198fcc11ef7d42fee22a7d0f943370e62d1c5d4aa589ad78428f
MD5 c7f64a8569e3369ebed5fec0579acfed
BLAKE2b-256 d257efe299e4e1c73e133098673eac1636a7532a7b9031e315dbf26f7b84d108

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dcbaa34e185a8bfb51ca33b7792090ff3d8771eb524711a304a69b4663b9a373
MD5 da9190804d9c1aacdf8f898ad7a7e94b
BLAKE2b-256 9b32850777136de89e5c10ed3e136529c7f98de6abcc329e40d820352817cccf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9247a1ca6e92449147ca18a66b02fe5d5e82d79e7982a40e10ea2ae93dd233aa
MD5 e5f3445dad6d1220a2b9d3b9148c1260
BLAKE2b-256 83f7ab517b41f72695072a04530f98f9f29a6f25f856bebf6b9e9daef495ac84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0c80befc97068d02ed31c84e268e1e6576076fe402d9bf1f6cdaddcd2e323eb2
MD5 66ca828f8530ca06fda203e9891e613d
BLAKE2b-256 4b6f926226da228547eeb12e09ebc4f99cdec78a3c91621be14458a701d99be9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c37a979091d06d5e0dcb918ed8d7c368c58a361223db1f0a33e3ee6ae8f46e14
MD5 3fead2ca1a4df18accc77644046ebe48
BLAKE2b-256 bed8bc9b87136eebca323605422cc5288558300e6e09c33358fd66ec440b2e49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 035621a305575f3436205598523a58e5b8ac80d7cefdb18d4316a2817399e5cd
MD5 4584b0863956025f1d17b96bb0e0d195
BLAKE2b-256 fe707d47fe0df560defafa30ed13710752e57ef7a7184a84edcdab99db2f9d9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 e81d2e05d1c62619fefe0a805cb17134082c1e916c8db6d057fea00ab986ab62
MD5 37ddba54dd3c7ec394458d37ba46a3f4
BLAKE2b-256 d03df64633d9d279a302c9f6fefb5ec2c836a520a5553cb2e0e07f4c87e36ee1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 eef9b7def62c44cddec7d4937b1f4b31444960fd178d22b7a6b9c4f4f705501f
MD5 77b36ec769317709f24f26198893111b
BLAKE2b-256 0d4b28aa8417bc498d9654b19db91fe9868bc7d6cc482de4bebaa0596d87bc0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cande_wrapper-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 5a5868005b470c3f7fd60a276344fe4598a4242dd0f58cd2e78424bf42bab3c4
MD5 acaabb27c7f20fdea5daea2a1b6f4ff7
BLAKE2b-256 becbf9559c44390db1ff97b81b9b35767875c561c7f5517ed6ede704b303faf4

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