HGD Troubleshooting Guide
This guide helps you resolve common issues when installing and using HGD.
Table of Contents
- Installation Issues
- Runtime Errors
- Performance Issues
- Output Issues
- Platform-Specific Issues
- Getting More Help
Installation Issues
Problem: pip install -e . fails with "No module named 'skbuild'"
Error message:
Solution:
Problem: CMake not found
Error message:
Solution:
Install CMake:
- Ubuntu/Debian: sudo apt-get install cmake
- macOS: brew install cmake
- Windows: Download from cmake.org
After installing, verify:
Problem: C++ compiler not found
Error message:
orSolution:
Linux:
macOS:
Windows: - Install Visual Studio Community Edition - Select "Desktop development with C++" workload during installation
Problem: OpenMP not found
Error message:
Solution:
Ubuntu/Debian:
macOS:
Windows: OpenMP should be included with Visual Studio. If not, reinstall with C++ support.
Problem: "No module named 'HGD'" after installation
Symptoms:
Solution: 1. Make sure you're in the correct directory:
-
Reinstall:
-
Verify Python is using the correct environment:
-
If using virtual environment, make sure it's activated:
Runtime Errors
Problem: AttributeError: 'dict_to_class' object has no attribute 'defined_time_step_size'
Error message:
Cause: When inertia is set to true, the parameter defined_time_step_size is required but missing.
Solution: Add this line to your JSON5 configuration file:
The value 1e-3 is a reasonable starting point for most simulations. Adjust based on your needs:
- Smaller values (e.g., 1e-4): More accurate but slower
- Larger values (e.g., 1e-2): Faster but may be unstable
Problem: Simulation starts but immediately crashes
Error message:
Common causes:
-
Grid too small: Increase
nx,ny, ornm -
Invalid boundary condition: Check
boundariesparameter -
Incompatible parameters: Some combinations don't work
- Can't have outlet without appropriate boundary
IC_modemust match geometry
Problem: KeyError or missing parameter
Error message:
Solution:
HGD uses default values from json/defaults.json5. If a required parameter is missing:
- Check parameter name spelling
- Ensure parameter is defined in either:
- Your JSON5 file, or
-
json/defaults.json5 -
For new/custom parameters, make sure they're properly initialized
Problem: "Cannot allocate memory" or MemoryError
Error message:
orCause: Grid resolution too high for available RAM.
Solution:
-
Reduce resolution:
-
Estimate memory usage:
- Memory ≈
nx * ny * nm * 8 bytes * number_of_fields - Example: 50×50×20 grid ≈ 50×50×20×8×10 = 40 MB (manageable)
-
Example: 100×100×100 grid ≈ 100×100×100×8×10 = 800 MB (high)
-
Close other applications to free RAM
-
Use a machine with more memory
Problem: FileNotFoundError for JSON file
Error message:
Solution:
-
Check you're in the HGD directory:
-
Use relative or absolute path:
Performance Issues
Problem: Simulation is very slow
Symptoms: - Takes hours to complete - Progress bar shows < 10 iterations/second
Solutions:
-
Reduce resolution (fastest improvement):
-
Use faster motion model:
-
Reduce simulation time:
-
Save less frequently:
-
Disable unnecessary calculations:
-
Use parallel execution:
Problem: Simulation uses 100% CPU but is still slow
This is normal behavior. Granular simulations are computationally intensive.
To improve:
- Use the C++ motion model (d2q4_cpp)
- Reduce grid resolution
- Ensure OpenMP is properly installed for parallel C++ execution
Output Issues
Problem: No output files generated
Symptoms:
- Simulation completes
- No files in output/ directory
Solutions:
-
Check plot/video parameters:
-
Check save_inc is not too large:
-
Verify output directory:
-
Check for error messages during simulation
Problem: Videos are not created
Symptoms: - PNG images are generated - No MP4 files
Cause: ffmpeg is not installed or not in PATH.
Solution:
Ubuntu/Debian:
macOS:
Windows: - Download from ffmpeg.org - Add to system PATH
Workaround: Use PNG images directly or create videos manually:
cd output/hopper/repose_angle_30/
ffmpeg -framerate 10 -pattern_type glob -i 'nu_*.png' -c:v libx264 nu.mp4
Problem: Images look wrong or corrupted
Symptoms: - All white or all black images - Strange patterns - NaN values
Solutions:
-
Check initial conditions:
-
Check material properties:
-
Reduce time step if using inertia:
Platform-Specific Issues
macOS: "Library not loaded" error
Error message:
Solution:
Add the export line to your ~/.zshrc or ~/.bash_profile.
Windows: "DLL load failed"
Error message:
Solution: 1. Install Visual C++ Redistributable from Microsoft 2. Reinstall with Visual Studio C++ tools properly configured 3. Use Python from python.org (not Microsoft Store version)
Linux: "Permission denied" when running
Error message:
Solution:
# Make sure you have write permission in the directory
chmod +x HGD/main.py
# Or run from your home directory with full paths
Getting More Help
If your problem isn't listed here:
1. Check Existing Issues
Visit GitHub Issues to see if others have encountered the same problem.
2. Enable Debug Output
Run with verbose output:
3. Check Your Configuration
Verify your JSON5 file syntax:
4. Gather Information
When reporting issues, include:
- Operating system and version
- Python version (python --version)
- HGD version/commit
- Complete error message
- JSON5 configuration file
- Steps to reproduce
5. Ask for Help
- Matrix Chat: https://matrix.to/#/!UZnyhaLhQymfFbLJYI:matrix.org?via=matrix.org
- GitHub Issues: https://github.com/benjym/HGD/issues
- Email: Contact authors listed in README.md
6. Minimal Example
When asking for help, create a minimal example that reproduces the issue:
Common Warnings (Not Errors)
These warnings are usually safe to ignore:
- From numpy/matplotlib, not from HGD - Does not affect functionality - matplotlib backend warnings - Usually harmless - Progress bar display issue - Doesn't affect simulation accuracyQuick Diagnostic Checklist
When something goes wrong, check:
- [ ] Python 3.9+ installed?
- [ ] C++ compiler installed?
- [ ] CMake 3.15+ installed?
- [ ] OpenMP installed?
- [ ]
pip install -e .completed successfully? - [ ] Running from HGD directory?
- [ ] JSON5 file exists and is valid?
- [ ] JSON5 file has required parameters?
- [ ] Sufficient RAM for grid size?
- [ ] Enough disk space for output?
Happy troubleshooting! If all else fails, start with the simplest example (collapse.json5) and build up from there. 🔧