URAMSES is a project that enables the integration of custom user models into PyRAMSES (Python interface for RAMSES power system simulator) and STEPSS. This repository provides the framework and tools needed to compile and link your own Fortran models with the simulation environment.
- Prerequisites
- Project Structure
- Model Types
- Quick Start
- Building
- Adding Custom Models
- Using Your Models
- Examples
- Troubleshooting
- Platform Comparison
- Documentation & Support
- License
- Microsoft Visual Studio (2019 or later recommended)
- Intel oneAPI Fortran Compiler (formerly Intel Fortran)
- PyRAMSES (Python package) or STEPSS (Java package)
For detailed installation instructions of the Intel oneAPI Fortran compiler, refer to the included PDF: Installing the Intel oneAPI Fortran compiler.pdf
- gfortran (GNU Fortran compiler)
- OpenBLAS (optimized BLAS library)
- PyRAMSES (Python package)
Install dependencies on your Linux distribution:
# Ubuntu/Debian
sudo apt install gfortran libopenblas-dev
# Fedora/RHEL
sudo dnf install gcc-gfortran openblas-devel
# Arch Linux
sudo pacman -S gcc-fortran openblasURAMSES/
├── src/ # Source code files (common for Windows/Linux)
│ ├── c_interface.f90 # C interface for Python integration
│ ├── main.f90 # Main entry point (executable only)
│ ├── FUNCTIONS_IN_MODELS.f90 # Helper functions for models
│ ├── usr_exc_models.f90 # Exciter model associations
│ ├── usr_inj_models.f90 # Injector model associations
│ ├── usr_tor_models.f90 # Torque model associations
│ ├── usr_twop_models.f90 # Two-port model associations
│ └── usr_dctl_models.f90 # Discrete control model associations
├── my_models/ # Your custom models (common for Windows/Linux)
│ ├── exc_*.f90 # Exciter models
│ ├── inj_*.f90 # Injector models
│ ├── tor_*.f90 # Torque models
│ ├── twop_*.f90 # Two-port models
│ └── *.txt # Model parameter files
├── modules/ # Pre-compiled modules (Windows/Intel Fortran)
│ ├── *.mod # Module interface files
│ └── libramses.lib # Pre-compiled RAMSES library
├── modules_lin/ # Pre-compiled modules (Linux/gfortran)
│ ├── *.mod # Module interface files
│ └── libramses.a # Pre-compiled RAMSES library
├── URAMSES.sln # Visual Studio solution file (Windows)
├── dllramses.vfproj # DLL project - ramses.dll (Windows)
├── exeramses.vfproj # Executable project - dynsim.exe (Windows)
├── MDL.vfproj # Model library project (Windows)
├── Makefile.gfortran # Makefile for Linux builds
├── Release_intel_w64/ # Compiled output (Windows)
└── Release_gnu_l/ # Compiled output (Linux)
URAMSES supports several types of power system models:
- Exciters (
exc_*): Generator excitation system models - Injectors (
inj_*): Current/voltage injection models for faults/disturbances - Torque (
tor_*): Mechanical torque models for generators - Two-port (
twop_*): Two-port network models (e.g., SVC, STATCOM) - Discrete Control (
dctl_*): Discrete control system models
# Build everything (shared library + executable)
make -f Makefile.gfortran
# Run standalone simulation
./Release_gnu_l/dynsim- Open
URAMSES.slnin Visual Studio - Select
Release|x64configuration - Build → Build Solution
- Run
Release_intel_w64\dynsim.exe
- Check dependencies: The Makefile automatically verifies that gfortran and OpenBLAS are installed
- Auto-detect sources: Automatically finds all
.f90files insrc/andmy_models/directories - Compile sources: Compiles all detected source files
- Link: Links against pre-compiled
libramses.afrommodules_lin/and OpenBLAS - Output: Creates
ramses.soanddynsiminRelease_gnu_l/
Note: The Makefile uses wildcard to automatically detect all .f90 files in my_models/. You don't need to manually add new model files to the Makefile - just place them in my_models/ and rebuild.
make -f Makefile.gfortran # Build both ramses.so and dynsim (default)
make -f Makefile.gfortran dll # Build only ramses.so (shared library)
make -f Makefile.gfortran exe # Build only dynsim (executable)
make -f Makefile.gfortran clean # Remove build artifacts
make -f Makefile.gfortran check-deps # Verify dependencies
make -f Makefile.gfortran help # Show helpAfter successful build, the following files will be in Release_gnu_l/:
Release_gnu_l/ramses.so # Shared library for PyRAMSES
Release_gnu_l/dynsim # Standalone executable
The solution contains three main projects:
-
dllramses (ramses.dll)
- Purpose: Creates the main dynamic link library for PyRAMSES integration
- Output:
ramses.dll- Used by PyRAMSES to access your custom models - Usage: Primary project for Python integration on Windows
-
exeramses (dynsim.exe)
- Purpose: Creates a standalone executable for direct simulation
- Output:
dynsim.exe- Command-line simulation tool - Usage: Run simulations directly without Python/Java interface
- Features: Includes all your custom models for standalone operation
- Open Solution: Open
URAMSES.slnin Microsoft Visual Studio - Verify Compiler: Ensure Intel Fortran compiler is properly configured
- Select Configuration: Choose
Release|x64configuration - Build: Right-click solution → "Build Solution"
All compiled files will be created in Release_intel_w64/:
ramses.dll- For PyRAMSES/STEPSS integrationdynsim.exe- Standalone executable
Place your generated .f90 model files (created by CODEGEN) into the my_models/ directory.
Linux: The Makefile will automatically detect and compile any .f90 files in this directory.
Windows: You'll need to add the file to the Visual Studio project (see step 3).
Example: If you create my_models/exc_MYMODEL.f90, it will be automatically included in Linux builds.
Edit the appropriate association file in src/ to register your models. This tells RAMSES which subroutine to call for your model.
For Exciters (src/usr_exc_models.f90):
select case (modelname)
case('YOUR_MODEL_NAME')
exc_ptr => your_model_subroutine
end selectFor Injectors (src/usr_inj_models.f90):
select case (modelname)
case('YOUR_MODEL_NAME')
inj_ptr => your_model_subroutine
end selectFor Torque Models (src/usr_tor_models.f90):
select case (modelname)
case('YOUR_MODEL_NAME')
tor_ptr => your_model_subroutine
end selectFor Two-port Models (src/usr_twop_models.f90):
select case (modelname)
case('YOUR_MODEL_NAME')
twop_ptr => your_model_subroutine
end selectFor Discrete Control Models (src/usr_dctl_models.f90):
select case (modelname)
case('YOUR_MODEL_NAME')
dctl_ptr => your_model_subroutine
end selectImportant: The modelname in the case statement must match exactly the name used in your simulation case files.
For Windows builds, you need to manually add the model file to the Visual Studio project:
- Right-click on the
dllramsesproject in Solution Explorer - Select "Add" → "Existing Item"
- Navigate to
my_models/and select your.f90files - Click "Add"
Note: For Linux builds, this step is not required. The Makefile automatically detects all .f90 files in my_models/ using wildcard, so your new model will be compiled automatically.
-
Linux:
make -f Makefile.gfortran clean all
The Makefile will automatically compile your new model file(s) from
my_models/. -
Windows: Rebuild the solution in Visual Studio (Build → Rebuild Solution)
While not strictly required, following naming conventions helps organization:
- Exciters:
exc_*.f90(e.g.,exc_MYMODEL.f90) - Injectors:
inj_*.f90(e.g.,inj_MYMODEL.f90) - Torque:
tor_*.f90(e.g.,tor_MYMODEL.f90) - Two-port:
twop_*.f90(e.g.,twop_MYMODEL.f90) - Discrete Control:
dctl_*.f90(e.g.,dctl_MYMODEL.f90)
import pyramses
# Linux
ram = pyramses.sim('/path/to/your/URAMSES/Release_gnu_l')
# Windows
ram = pyramses.sim(r'C:\path\to\your\URAMSES\Release_intel_w64')
# Your models are now available for use in simulations// Use ramses.dll with STEPSS Java interface
// Your custom models will be available in STEPSS simulations# Linux
cd Release_gnu_l
./dynsim
# Windows
cd Release_intel_w64
dynsim.exeThe my_models/ directory contains several example models:
exc_ENTSOE_lim.f90: ENTSO-E exciter model with limitersexc_GENERIC3.f90: Generic exciter model type 3exc_GENERIC4.f90: Generic exciter model type 4exc_ST1A.f90: IEEE ST1A exciter modelinj_AIR_COND1_mod.f90: Air conditioning load modeltor_ENTSOE_simp.f90: Simplified ENTSO-E torque model
-
gfortran not found
# Ubuntu/Debian sudo apt install gfortran -
OpenBLAS not found
# Ubuntu/Debian sudo apt install libopenblas-dev -
Module files not found
- Ensure
modules_lin/directory exists and contains.modfiles - Verify
libramses.ais present inmodules_lin/
- Ensure
-
Undefined reference errors
- Check that your model subroutine names match those in association files
- Ensure all dependencies are properly linked
- Verify that OpenBLAS is properly installed
-
New model not being compiled
- Ensure the model file has a
.f90extension - Check that the file is in the
my_models/directory - Run
make -f Makefile.gfortran clean allto force a full rebuild
- Ensure the model file has a
- Compilation Errors: Ensure Intel Fortran compiler is properly installed and configured
- Missing Models: Verify model names match exactly in association files
- DLL Loading: Check that the path to
ramses.dllis correct in PyRAMSES - Model Parameters: Ensure parameter files are properly formatted
- Check compiler output for compilation errors
- Verify model subroutine names match exactly in association files
- Test with simple models first before complex implementations
- On Linux, use
ldd Release_gnu_l/ramses.soto check library dependencies
| Feature | Linux | Windows |
|---|---|---|
| Compiler | gfortran | Intel Fortran |
| BLAS Library | OpenBLAS | Intel MKL |
| Build System | Makefile | Visual Studio |
| Output Library | ramses.so |
ramses.dll |
| Output Executable | dynsim |
dynsim.exe |
| Output Directory | Release_gnu_l/ |
Release_intel_w64/ |
| Module Directory | modules_lin/ |
modules/ |
| Model Auto-Detection | ✅ Automatic (wildcard) | ❌ Manual (VS project) |
For comprehensive PyRAMSES documentation, visit: https://pyramses.sps-lab.org
For issues and questions, contact:
- Sustainable Power Systems Lab (SPS-L)
- Website: https://sps-lab.org
- Email: info@sps-lab.org
This project is licensed under the Academic Public License. See LICENSE.rst for details.
Last Updated: January 2026