Skip to main content

pyCAFE: a 2D finite element framework for solving acoustic equations.

Project description

pyCAFE is a Python based 2D finite element framework for solving acoustic problems in the frequency domain.

The library is designed for research and engineering applications in acoustics. It provides a clear and modular workflow for defining the fluid medium, geometry, boundary conditions, assembling the acoustic finite element system, and solving the Helmholtz equation.

pyCAFE is particularly suited for numerical studies and for extending classical acoustic FEM formulations toward more advanced models.

The authors welcome contributions from the community to enhance and expand the software’s capabilities. Even if the studies behind the writing of the software were broad and deep, there is always room for improvement and new features. A lot of work is still needed to make pyCAFE a fully-featured acoustic FEM package.

Typical workflow

A typical pyCAFE analysis follows an explicit and modular pipeline:

  1. Create geometry and mesh (optional step)

  2. Load fluid properties

  3. Define the computational geometry

  4. Load the finite element mesh

  5. Assign boundary conditions

  6. Assemble the acoustic finite element system

  7. Solve the Helmholtz equation in the frequency domain

Each step is handled by a dedicated function, making the workflow easy to understand, debug, and extend.

Example

The following example illustrates a complete acoustic simulation workflow using pyCAFE:

import pycafe

# Load fluid properties
fluid = pycafe.load_fluid("air")

# Create geometry
msh_file = pycafe.create_geometry(c0=fluid["c0"])

# Load mesh
nodes, elements, boundaries = pycafe.load_mesh("rectangle_CQUAD8.msh")

# Assign boundary conditions
bc = pycafe.assign_boundary_conditions(
    boundaries=boundaries,
    nodes=nodes,
)

# Assemble the acoustic FEM system
system = pycafe.prepare_acoustic_system(
    nodes=nodes,
    elements=elements,
    boundaries=boundaries,
    rho=fluid["rho"],
    c0=fluid["c0"],
    bc=bc,
    debug=True,
)

# Solve the acoustic problem
results = pycafe.run_analysis(
    system=system,
    nodes=nodes,
    boundaries=boundaries,
    rho=fluid["rho"],
)

Project structure

The core package is organized as follows:

pycafe/
    boundary_condition/    Acoustic boundary condition definitions
    build_matrices/        Finite element matrix assembly
    core/                  Workflow utilities
    create_geom/           Geometry definition and mesh visualization
    material/              Fluid and material models
    solver/                Helmholtz and modal solvers
    post_processing/       Post processing and visualization tools

tests/
    Basic unit tests

docs/
    Sphinx documentation source and build files

Documentation

The project documentation is built using Sphinx and can be hosted via Read the Docs.

To build the documentation locally, run the following commands from the project root directory:

cd docs
make clean
make html

The generated HTML documentation will be available in docs/build/html.

Development and testing

Unit tests are located in the tests/ directory and can be run using:

pytest

Contributions, bug reports, and feature requests are welcome.

License

pyCAFE is released under the MIT License. See the LICENSE file for more information.

DOI

DOI

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

pycafe_acoustics-1.0.0.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

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

pycafe_acoustics-1.0.0-py3-none-any.whl (51.4 kB view details)

Uploaded Python 3

File details

Details for the file pycafe_acoustics-1.0.0.tar.gz.

File metadata

  • Download URL: pycafe_acoustics-1.0.0.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for pycafe_acoustics-1.0.0.tar.gz
Algorithm Hash digest
SHA256 41fc7dbe604c1c2491588cc0475bfc1636dbde59b97a9a8b4549c33f6d8d486f
MD5 45383a20f9b8ea1a7e5fd54d42976b10
BLAKE2b-256 b701353d5d7d0e83f64b750990200224ae72b264fbf3733058b4d4c3c8303799

See more details on using hashes here.

File details

Details for the file pycafe_acoustics-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pycafe_acoustics-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c8e3690d4fc46abda3c2850bbd35df44279df500c012d35406e414f7340a252
MD5 b237c9e6f39b991b371b6aca0cf85fdc
BLAKE2b-256 2ffcce546ef1246b91836ab01d26903d9dfa1ef87e5aec18a9176ffd390ac9f8

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