Learning-based Modal Sound Synthesis with Open-Source CalculiX FEM Solver
arXiv | Project Page | Original NeuralSound
This is a fork of NeuralSound that replaces the commercial Abaqus FEM solver with the open-source CalculiX solver for modal analysis.
- Open-Source FEM Solver: CalculiX replaces Abaqus (no commercial license needed)
- 2.8x Faster: CalculiX outperforms Abaqus in modal analysis
- 60% Less Memory: More efficient memory usage
- < 0.05% Error: Validated against Abaqus results
- Easy Build: Nix-based build system for reproducible compilation
| Component | Method | Library |
|---|---|---|
| Modal Analysis | FEM (Finite Element Method) | CalculiX |
| Acoustic Transfer | BEM (Boundary Element Method) | Bempp-cl |
| Deep Learning | Sparse CNN | PyTorch + Minkowski Engine |
NeuralSound-CalculiX/
├── src/ # Source code
│ ├── classic/ # Classical FEM/BEM methods
│ │ ├── fem/ # FEM implementation
│ │ │ ├── calculix_adapter.py # CalculiX adapter
│ │ │ ├── femModel.py # FEM model
│ │ │ └── solver.py # Lanczos/LOBPCG solvers
│ │ └── bem/ # BEM implementation (Bempp)
│ └── net/ # Neural network architectures
│
├── external/ # External tools
│ └── calculix/ # CalculiX FEM solver
│ ├── bin/ # Pre-compiled binary
│ │ └── ccx # CalculiX executable
│ └── src/ # Source code for compilation
│
├── dataset/ # Training/testing data
├── dataset_scripts/ # Data generation scripts
├── scripts/ # Utility scripts
├── tests/ # Test files
├── docs/ # Documentation
│
├── acoustic/ # Acoustic solver training
├── vibration/ # Vibration solver training
├── deepmodal/ # DeepModal training
├── blender/ # Blender integration
│
├── flake.nix # Nix build configuration
└── environment.md # Environment setup guide
The pre-compiled CalculiX binary is included in external/calculix/bin/ccx.
import numpy as np
from src.classic.fem.calculix_adapter import CalculixAdapter
from src.classic.fem.femModel import Material
# Load voxel model
voxel = np.load('dataset/voxel/model.npy')
# Run modal analysis with CalculiX
adapter = CalculixAdapter()
vals, vecs = adapter.modal_analysis(voxel, Material.Ceramic, num_modes=20)
# Convert to frequencies
freqs = np.sqrt(vals) / (2 * np.pi)
print(f"Frequencies: {freqs}")# Install Nix (if not installed)
curl -L https://nixos.org/nix/install | sh
# Build CalculiX
nix build
# The binary will be in result/bin/ccx
cp result/bin/ccx external/calculix/bin/git clone https://github.com/jiaqiwang969/NeuralSound-CalculiX.git
cd NeuralSound-CalculiXconda create -n neuralsound python=3.7 -y
conda activate neuralsound
# Install Bempp-cl (for acoustic transfer)
conda install pyopencl pocl -c conda-forge -y
pip install plotly gmsh
git clone https://github.com/bempp/bempp-cl
cd bempp-cl && python setup.py install && cd ..
# Install PyTorch and dependencies
pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install scipy matplotlib numba tensorboard tqdm meshio
# Install PyTorch Scatter
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu113.html
# Install Minkowski Engine
git clone https://github.com/NVIDIA/MinkowskiEngine.git
cd MinkowskiEngine && python setup.py install && cd ..python verify_project.pycd dataset_scripts
# 1. Voxelize meshes
python voxelize.py "../dataset/mesh/*" "../dataset/voxel"
# 2. Modal analysis (using CalculiX)
python modalAnalysis.py "../dataset/voxel/*" "../dataset/eigen" --solver calculix
# 3. Generate LOBPCG matrices
python lobpcgMatrix.py "../dataset/voxel/*" "../dataset/lobpcg"
# 4. Acoustic transfer (using BEM)
python acousticTransfer.py "../dataset/eigen/*" "../dataset/acousticMap"
# 5. DeepModal data
python deepModal.py "../dataset/eigen/*.npz" "../dataset/deepmodal"| Solver | Command | Speed | Requirements |
|---|---|---|---|
| CalculiX | --solver calculix |
⭐⭐⭐⭐⭐ | Nix (for build) |
| Lanczos | --solver lanczos |
⭐⭐⭐ | SciPy |
| LOBPCG | --solver lobpcg |
⭐⭐⭐⭐ | CUDA |
cd dataset_scripts
python splitDataset.py "../dataset/lobpcg/*.pt"
cd ../vibration
python train.py --dataset "../dataset/lobpcg" --tag default --cuda 0cd dataset_scripts
python splitDataset.py "../dataset/acousticMap/*.npz"
cd ../acoustic
python train.py --dataset "../dataset/acousticMap" --tag default --cuda 0cd dataset_scripts
python splitDataset.py "../dataset/deepmodal/*.pt"
cd ../deepmodal
python train.py --dataset "../dataset/deepmodal" --tag default --cuda 0| Model | Avg Error | Max Error | Speedup |
|---|---|---|---|
| Box | 0.0502% | 0.0839% | 2.9x |
| Sphere | 0.0425% | 0.1639% | 2.8x |
| Cylinder | 0.0313% | 0.0762% | 2.5x |
| Overall | 0.0413% | 0.1639% | 2.8x |
See docs/CALCULIX_VS_ABAQUS_COMPARISON.md for detailed comparison.
| Document | Description |
|---|---|
| CALCULIX_QUICKSTART.md | Quick start guide |
| TECHNICAL_ARCHITECTURE.md | Technical architecture |
| BEMPP_TECHNICAL_DETAILS.md | BEM implementation details |
| CALCULIX_VS_ABAQUS_COMPARISON.md | Validation results |
1. Mesh → Voxelization → Voxel Grid (32³)
↓
2. Voxel → CalculiX FEM → Modal Analysis (eigenvalues + eigenvectors)
↓
3. Modes → Bempp BEM → Acoustic Transfer (FFAT Map)
↓
4. Sound Synthesis
- Modal Analysis (FEM): Solves generalized eigenvalue problem Kφ = λMφ
- Acoustic Transfer (BEM): Solves Helmholtz equation ∇²p + k²p = 0
- Neural Networks: Accelerate both FEM and BEM computations
- NeuralSound: Original project license
- CalculiX: GPL v2
If you use this code, please cite:
@article{jin2021neuralsound,
title={NeuralSound: Learning-based Modal Sound Synthesis with Acoustic Transfer},
author={Jin, Xutong and Sheng, Yutong and Jiang, Tianjia and Wang, Bin},
journal={arXiv preprint arXiv:2108.07425},
year={2021}
}- NeuralSound - Original implementation
- CalculiX - Open-source FEM solver
- Bempp-cl - BEM library
- jtufem - CalculiX build configuration
- Original Author: Xutong Jin ([email protected])
- This Fork: Jiaqi Wang