Giter Site home page Giter Site logo

anysim's Introduction

AnySim - Framework for solving arbitrary linear systems

Class hierarchy

AnySim : root class implementing the Modified Born series iteration
 │
 └─ GridSim : base class for all simulations on a grid
     │
     ├─ DiffuseSim : solves the diffusion equation
     ├─ Pantograph : solves the pantograph equation
     └─ HelmholtzSim : solves the Helmholtz equation

Helper classes:
   Grid
   DisplayCallback
   TerminationCondition
   State
   *Options classes : contain a list of options (and code for validating them)
                      for constructing an object of the corresponding type

Implementing a solver

The general structure of the modified Born series algorithm is implemented already. To implement a solver for a specific linear problem, one needs to implement a simulation object inheriting from AnySim or one of its derived classes (such as GridSim). See DiffuseSim for an example. The following methods should be implemented:

  • The constructor. Processes options and sets 'medium', 'transform' and 'propagator' properties to the correct operators.

The constructor

The constructor takes all information needed to describe a specific linear system (e. g. a refractive index map) and a set of options. The returned object fully describes the linear system and all details of the simulation.

The constructor should check the validity of all inputs and fill in defaults for missing options. Importantly, it should set the properties medium and propagator. Note that the medium_adj and propagator_adj properties are experimental at the moment.

.medium: Returns a handle to a function implementing x -> (1-V) x. Typically, this is implemented as a multiplication with a scattering potential in the spatio-temporal domain. For the diffusion equation, for example, the function performs a multiplication with the absorption-(inverse)diffusion tensor. In preparing the medium, the scattering potential is first shifted by V0 to minimze ‖V‖, and then scaled to have ‖V‖<1. The matrices responsible for this scaling (Tl and Tr) are stored in the Medium object.

.propagator: Returns a handle to a function implementing x -> (L+1)^{-1} x Typically, this is implemented as a multiplication with a fixed function in the spatio-temporal frequency domain.

Algorithm implementation

Preconditioning

The initial linear equation (L_raw+V_raw) u_raw=s_raw
is first converted to (L+V) u = s

with: L = Tl (L_raw+V_0) Tr     and   V = Tl (V_raw-V0) Tr
introducing: u = Tr^(-1) u_raw   and  s = Tl s_raw

with Tl and Tr diagonal invertible pre-conditioning matrices. V0
is an operator. Tl, Tr, and V0 are chosen such that
    % 1. L, V and are dimensionless
    % 2. The operator norm ||V-V0|| is minimized
    % 3. ||V|| < 1 (but as close to 1 as conveniently possible)

Implementation:
Tl, V0 and Tr are computed using the center_scale function. Currently,
for vector potentials Tl = Tr are diagonal matrices, and for scalar
potentials Tl = 1 and Tr is a scalar.

Iteration

In the manuscript, the following iteration is derived: u -> (B Li B + 1 - B) u + B Li s

which is implemented as: t1 = B u + s t1 -> Li t1 u -> u + alpha B (t1 - u)

requires: 1 temporary storage (t1) 1 field storage (u) 1 potential storage (B) 1 propagator storage (Li, may be computed on the fly in some implementations!)

Bookkeeping

While running the algorithm, a State object is passed to all operator function calls. The State object is of handle type (a reference) and contains bookkeeping information (such as the iteration number) and can be used to store diagnostics and debugging information.

GridSim

Data Storage

GridSim objects work with simulation data that can be represented on a regular grid. The data may be scalar, vector, or matrix-valued.

When storing scalar fields, 'u' is an N-dimensional array. For vector fields or tensor fields, dimensions are added at the start of the array. For example to store a 3-element vector in a 3-D simulation: size(u) = [3, Nx, Ny, Nz]

Each dimension may have a different pixel pitch and unit, this metadata is stored in a SimGrid object.

anysim's People

Contributors

ivovellekoop avatar tttom avatar

Stargazers

Swapnil avatar  avatar  avatar Lee, Dohyeon avatar  avatar

Watchers

James Cloos avatar  avatar  avatar Kostas Georgiou avatar  avatar

Forkers

corilim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.