How cselab/odil works
Main project components
• Core Engine: Represented by modules such as core.py, core_min.py, optimizer.py, runtime.py, and linsolver.py. These are responsible for problem formulation (discrete loss), optimization methods (gradient-based optimizers like Adam, L-BFGS, and Newton’s method), and solving the PDEs.
• Utility and I/O: Modules like io.py, cache.py, util.py, and history.py support workflow operations. They handle file input/output, result caching, logging of history, and general utilities.
• Visualization: Plotting modules (plot.py, plotutil.py, and the provided mplstyle file) indicate built-in data/field visualization for debugging and interpreting results.
• Examples/Demo Applications: The multiple examples directories (basic, heat, heat_tmax, infer_constant, poisson, velocity_from_tracer, wave) serve as concrete use cases and demos. They show how the framework is applied to different PDE cases.
• Testing: The tests directory shows unit tests and integration tests that ensure correct functionality.
Relationships and interactions between components
• Data Flow: Input PDE models, boundary conditions, and discretization data are fed into the core engine. These components then call the backend for automatic differentiation and numerical evaluations.
• Optimization Loop: The core modules interact with the optimizer and linear solver to iteratively minimize the loss function while updating system state.
• I/O and Logging: Data throughout the optimization iterations are managed by the I/O utilities and logger/history modules, with results possibly sent to the visualization modules.
• External Integration: Clearly mark the dependency on external libraries (TensorFlow/JAX) that provide the automatic differentiation engine, and note optional GPU support via CUDA_VISIBLE_DEVICES configurations.
• Demo and Test Bifurcation: Show that the framework’s modular design permits separate demo applications (in the examples directory) and a suite of tests (in tests).
Architectural patterns and design principles
• Modular Design: Each major functionality (core computations, optimizers, plotting, and I/O) is encapsulated in its own module, making the system easy to extend.
• Abstraction of Backends: The “backend” module abstracts the automatic differentiation engine, allowing seamless switching between frameworks like TensorFlow and JAX.
• Separation of Concerns: The examples act as isolated demonstrations that interact with, but are separated from, the core mechanics. This illustrates a clear separation between library functionality and application/demonstration code.
• Reusability and Extensibility: The framework is designed for solving a class of optimization problems with PDEs, making it reusable across different domains.
Relevant technologies, frameworks, or libraries
• Python (the main language)
• TensorFlow / JAX (for automatic differentiation)
• Standard plotting libraries (e.g., Matplotlib inferred from the mplstyle)
• C++ with autodiff and Emscripten for interactive web demos (as noted in the README demos)
Final Assembly
• Modular interactions to capture how the framework is both extendible and testable.