Skip to main content

Interpolator of different kind of loads and BC to APDL format

Project description

InterpCore

A Python library for interpolating physical field data (electromagnetic forces, heat flux, etc.) between different mesh representations and exporting to ANSYS APDL format.

Features

  • Multiple interpolation kernels: Distance-weighted, FEM-based, K-nearest neighbors, closest point
  • Flexible query methods: K-nearest neighbors or radius-based search
  • Support for multiple load types:
    • EM forces (3-component vector fields)
    • Heat flux (scalar fields)
    • Heat generation (volumetric)
    • Heat Transfer Coefficient + bulk fluid temperature (convection BCs)
  • Export to ANSYS APDL: Direct export of interpolated results in APDL format
  • Visualization: Built-in VTK export for ParaView or PyVista visualization
  • Efficient: KDTree-based spatial queries for fast neighbor searches

Installation

pip install interpcore

Quick Start

from interpcore.interpolator import Interpolator
from interpcore.config import InterpolationConfig, QUERY_TYPE, INTERPOLATED_LOAD_TYPE
from interpcore.kernels import INTERPOLATION_KERNEL

# Configure interpolation
config = InterpolationConfig(
    method=QUERY_TYPE.K,  # type of neighbour search
    param=5,  # parameter relative to the neighbour search (K or radius)
    max_distance=2.0, # filter by a max radius of search (in case of K is used)
    coincidence_tolerance=0.01, # tolerance to consider two nodes coincident
    kernel=INTERPOLATION_KERNEL.DISTANCE_WEIGHTED, # How to interpolate
    multithread=False, # use or not multithread
    interpolated_load=INTERPOLATED_LOAD_TYPE.EM_FORCE # type of load that is being interpolated
)

# Define file column indices. This gives the column index in the input files
file_idx = {"ids": 0, "dest_x": 1, "src_x": 1, "val": 4}

# Create interpolator and run
interpolator = Interpolator(
    path_to_src_folder="source_data",
    path_to_dest_mesh="destination_mesh.txt",
    config=config,
    file_idx=file_idx
)

# Interpolate all source files
interpolator.interpolate_all()

# Export to ANSYS format
interpolator.export_to_ansys("output_directory")

# Optional: Build VTK for visualization. If outdir=None they are not exported
interpolator.build_vtk_output(outdir="vtk_output")

Examples

Complete working examples with sample data are available in the doc/ folder:

Each example includes:

  • Sample mesh files
  • Sample data files
  • Jupyter notebook with full workflow
  • Visualization with PyVista

Configuration Options

Query Methods

  • QUERY_TYPE.K: K-nearest neighbors (param = number of neighbors)
  • QUERY_TYPE.RADIUS: Radius-based search (param = radius in same unit as coordinates)

Interpolation Kernels

Source-to-target

Each source point is distributed to destination neighbours:

  • DISTANCE_WEIGHTED: Weight by inverse distance
  • FEM: FEM-based interpolation

Target-to-source

A value is assigned to each destination point based on source neighbours

  • CLOSEST: Use closest source point value
  • AVERAGE: Simple average of neighbors
  • AVERAGE_WEIGHTED: Average the neighbours values but weighting them by distance (the closer the more important).

Load Types

  • EM_FORCE: 3-component vector fields (Fx, Fy, Fz). If "vol" column is provided the forces are interpreted as force densities and will be multiplied by the volume.
  • HEAT_FLUX: Scalar fields for surface heat flux
  • HEAT_GEN: Scalar fields for volumetric heat generation
  • HTC: 2-component convection boundary condition — Heat Transfer Coefficient and bulk fluid (reference) temperature. Exported as SFE,,CONV,1 and SFE,,CONV,2 in APDL.

File Format

The file format is pretty free, header, no header, commas, tabs.... The important part is that the correct index columns are specified when creating the interpolator.

Destination mesh input files can be created using the apdl scripts included in this repository here.

Requirements

  • Python ≥ 3.10
  • scikit-learn
  • pandas
  • tqdm
  • pyvista

License

Licensed under the European Union Public Licence (EUPL) 1.2

Authors

Developed by the F4E mechanical team

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

interpcore-1.0.0.tar.gz (312.6 kB view details)

Uploaded Source

Built Distribution

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

interpcore-1.0.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: interpcore-1.0.0.tar.gz
  • Upload date:
  • Size: 312.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for interpcore-1.0.0.tar.gz
Algorithm Hash digest
SHA256 99d6d9fb8776ada42165b1487cc14c9f360b288485bd40aedf804a0a88256c1f
MD5 2dcb1f284483a390fb860d9566d32785
BLAKE2b-256 f64f64e2182a4beb51689027f3e25ffcd76a047a075215577c9bcfc0cc80e16d

See more details on using hashes here.

Provenance

The following attestation bundles were made for interpcore-1.0.0.tar.gz:

Publisher: build_publish.yml on Fusion4Energy/InterpCore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: interpcore-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for interpcore-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e774c7bc9df3c8a459d39913156cdbd067789f909abf4218ecf7b9f9d2765194
MD5 7edc12e79d1a406f31de6632bcbce5e8
BLAKE2b-256 2471e913d3fe63c510cfe6f0194494581ddd90a3d92b33c99419d7bf5ee98e07

See more details on using hashes here.

Provenance

The following attestation bundles were made for interpcore-1.0.0-py3-none-any.whl:

Publisher: build_publish.yml on Fusion4Energy/InterpCore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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