FLUX Scientific Computing Language - Domain-Specific Language for PDEs, CFD, and Computational Physics
Project description
FLUX Scientific Computing Language
Domain-Specific Language for PDEs, CFD, and Computational Physics
FLUX is a high-performance DSL designed for scientific computing, specializing in partial differential equations, computational fluid dynamics, electromagnetic simulations, and finite element analysis.
Features
Core Scientific Computing Features
- Native PDE Syntax: Write equations in mathematical notation (∂u/∂t = ∇²u)
- Advanced Mesh Support: Structured, unstructured, and adaptive mesh refinement
- Multi-Physics: CFD, electromagnetics, structural analysis, heat transfer
- GPU Acceleration: CUDA kernel generation and parallel execution
- Modern Solvers: Finite element, finite volume, and spectral methods
- Code Generation: Compile to C++, CUDA, Python for maximum performance
Implemented Features (v0.1.0)
- ✅ PDE-specific lexer with Unicode math operators (∇, ∂, ×, ⊗)
- ✅ Parser for PDE definitions and boundary conditions
- ✅ Mesh generation (structured grids, unstructured, AMR)
- ✅ Code generation backends (Python, C++, CUDA)
- ✅ Scientific templates (heat equation, Navier-Stokes, Maxwell)
- ✅ GPU kernel generation for parallel computing
- ✅ Field operations and mathematical operators
- ✅ Boundary condition specification
Installation
# Clone the repository
git clone https://github.com/yourusername/flux-lang.git
cd flux-lang
# Install dependencies
pip install numpy scipy matplotlib
# Optional: CUDA toolkit for GPU acceleration
# Download from https://developer.nvidia.com/cuda-downloads
Quick Start
Compile a FLUX Program
Compile FLUX scientific code to your target backend:
# Compile to Python (default)
python flux_scientific.py examples/heat_equation.flux
# Compile to CUDA for GPU acceleration
python flux_scientific.py examples/gpu_accelerated_cfd.flux -b cuda
# Compile to C++ for performance
python flux_scientific.py examples/navier_stokes_cavity.flux -b cpp
Interactive Scientific Computing
Start the interactive scientific environment:
python flux_scientific.py -i
Example session:
flux-sci> mesh StructuredGrid 50 50
Created StructuredGrid with 2601 nodes, 2500 cells
flux-sci> compile examples/heat_equation.flux python
Compiling examples/heat_equation.flux to python...
Generated code written to output/generated.py
Compilation successful!
Run Benchmarks
Test FLUX with included scientific benchmarks:
python flux_scientific.py --benchmark
Language Examples
Hello World
function main() {
print("Hello, FLUX World!")
}
main()
Variables and Types
// Immutable variable
let pi = 3.14159
// Mutable variable
var counter = 0
counter = counter + 1
// Constant
const MAX_SIZE = 100
// Type annotations (optional)
let name: string = "FLUX"
let age: int = 1
Functions
function add(a: int, b: int) -> int {
return a + b
}
// Async function (syntax supported, async not yet implemented)
async function fetch_data(url: string) -> string {
// Implementation
}
Vectors and AI Operations
// Create vectors
let embedding1 = embed("artificial intelligence")
let embedding2 = embed("machine learning")
// Semantic similarity using ~~ operator
let similarity = embedding1 ~~ embedding2
print("Similarity: " + str(similarity))
// Vector operations
let v1 = vector(1.0, 2.0, 3.0)
let v2 = vector(4.0, 5.0, 6.0)
let dot_product = v1 @ v2 // Matrix multiplication operator
Tensor Operations
// Create tensors
let matrix = tensor([[1, 2], [3, 4]])
let weights = tensor([[0.1, 0.2], [0.3, 0.4]])
// Matrix multiplication
let result = matrix @ weights
// Special tensors
let zeros_3x3 = zeros(3, 3)
let ones_2x4 = ones(2, 4)
let random_5x5 = random(5, 5)
Quantum Computing (Basic)
// Create a qubit
let q = qubit()
// Apply quantum gates
q = hadamard(q) // Put in superposition
// Quantum circuits (syntax supported)
quantum circuit bell_pair() {
classical {
// Classical preprocessing
}
quantum {
// Quantum operations
}
classical {
// Classical postprocessing
}
}
Control Flow
// If statement
if x > 0 {
print("Positive")
} else if x < 0 {
print("Negative")
} else {
print("Zero")
}
// While loop
while condition {
// Loop body
}
// For loop (syntax planned)
for item in collection {
process(item)
}
// Match expression (syntax supported)
match value {
1 => print("One"),
2 => print("Two"),
_ => print("Other")
}
Examples Directory
The examples/ directory contains several demonstration programs:
hello_world.flux- Basic hello world and string operationsfibonacci.flux- Recursive and iterative Fibonacci implementationsvectors_ai.flux- Vector operations and semantic similaritytensors_ml.flux- Tensor operations and ML conceptsquantum_basic.flux- Basic quantum computing demonstrations
Architecture
flux-lang/
├── src/
│ ├── __init__.py # Package initialization
│ ├── lexer.py # Tokenization
│ ├── parser.py # AST generation
│ └── interpreter.py # Execution engine
├── examples/ # Example FLUX programs
├── flux.py # CLI and REPL
└── README.md # This file
Development Status
FLUX is currently in early development (v0.1.0). The following features are planned:
Near-term Goals
- Complete type system implementation
- Async/await execution
- Import/module system
- Standard library expansion
- Error handling improvements
- Debugger support
Long-term Goals
- MLIR backend for compilation
- WebAssembly target
- GPU acceleration
- Distributed computing primitives
- Full quantum circuit simulation
- Package manager
- IDE plugins (VSCode, etc.)
Contributing
Contributions are welcome! Areas where help is needed:
- Standard Library: Implementing built-in functions and types
- Quantum Operations: Expanding quantum computing support
- AI Integration: Connecting to real LLM APIs
- Optimization: Performance improvements
- Documentation: Tutorials and examples
- Testing: Unit tests and integration tests
License
FLUX is open-source software. License details to be determined.
Acknowledgments
FLUX is inspired by:
- Shopify Liquid (templating philosophy)
- Python (syntax and simplicity)
- Rust (memory safety concepts)
- Julia (scientific computing)
- Q# (quantum computing)
- Mojo (AI compilation)
FLUX: Write once, run everywhere, understand everything.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flux_sci_lang-0.1.0.tar.gz.
File metadata
- Download URL: flux_sci_lang-0.1.0.tar.gz
- Upload date:
- Size: 52.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1d04c15fb0f6919d1aa7152cdf4e21e24ffc759efbeeb0997e758595a304371
|
|
| MD5 |
ed1544e12fedd333a3a3e9f21405da2c
|
|
| BLAKE2b-256 |
e666e6e76f95c20aacf62e738bccdc9dad8d99c3062e1171a31521e2c6f3eddb
|
File details
Details for the file flux_sci_lang-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flux_sci_lang-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79103160909510f252146fdb05a8ec24458d7f29764d206de7cb1ca2ce375198
|
|
| MD5 |
928224288f6dd2292b409a8a8afb49ca
|
|
| BLAKE2b-256 |
7a634c1186177c7848c2ea08e73142bf45c8014ed2bcf88c8d4f3ea655e47dbc
|