Giter Site home page Giter Site logo

disk-models's Introduction

Accretion Disk Radial Structure Models

A collection of radial structure models of various accretion disk solutions, i.e. the radial dependence of their geometrical, physical and thermodynamic quantities.

Models

The following models are included:

See the model's README files for more information and usage instructions related to each model.

Installation

To download and compile the model collection use

git clone --recursive https://github.com/mbursa/disk-models.git
cd disk-models
make

The recursive option makes sure all submodules are included too (see bellow).

Individual models can be compiled separately by running make in the directory of a particular model or by running

make -C models/<model_name>

Dependencies

Some of the models may have external dependencies, which are handled using git submodules that are located under libs subfolder. Submodules are downloaded and initialized automatically when git clone --recurse-submodules (for version >=2.13 of git) or git clone --recursive (for git versions >1.6.5 and <2.13) is used to clone the repository.

For already cloned repos, or older git versions (<1.6), use the following to initialize submodules:

git clone https://github.com/mbursa/disk-models.git
cd disk-models
git submodule update --init --recursive

Most models use SIM5 library.

Usage

The compilation produces a linux shared library (.so extension) for each disk model. These libraries can be linked to programs at compile-time or they can be loaded by a program dynamically at run-time.

The models can be used quite independently. However, the idea has been that the models are used along with SIM5 library to compute and compare the observed spectra and other characteristics.

Dynamic linking

tbd

Loading at runtime

Run-time loading in a program can be done using dlopen() function.

void* lib_handle;
int (*diskmodel_init)(double M, double a, char* params);
// open library
void* lib_handle = dlopen(modellib, RTLD_NOW);
// assign library function to a local variable
*(void**)(&diskmodel_init) = dlsym(handle, "diskmodel_init");
// execute library function 
diskmodel_init(10.0, 0.0, "");
// close the library
dlclose(handle);

A complete example of how to dynamicly load and use a disk model library in a program is provided in examples/runtime-loading.

Using in Python

The compiled shared object libraries with disk models can be also used in Python. In the root folder, there is a disk_model.py wrapper that handles loading the dynamic library and makes an interface to the library methods. A basic pattern of calling disk models in Python using disk_model.py is

root_path = 'path/to/disk_model.py'
sys.path.append(root_path)
from disk_model import DiskModel
model = DiskModel(root_path+'/models/nt/disk-nt.so', 10.0, 0.0, 'mdot=0.1')

A complete example of how to call disk model methods in Python is provided in examples/python.

Loading with SIM5 library

SIM5 library contains a ready-to-use interface for loading the disk models. It essentially uses the approach described above and provides a C interface to access the functions of a disk model library that takes care of implementing the dynamic linking. A brief example how it can be used:

#include "sim5lib.h"
// link the disk model libray disk-nt.so
diskmodel_init("./disk-nt.so", 10.0, 0.0, "mdot=0.1,alpha=0.1");
// call a funtion from the library (effective flux at raduis r = 10 r_g)
float F = diskmodel_flux(10.0);
// close the library
diskmodel_done();

Interface

Each disk model implements a unified set of functions that specify the quantities that each model provides.

A complete description of the interface is given in doc/interface.md.

Citing

If you have used this software in your work, please acknowledge it by citing its ASCL record ascl:2002.022. The BibTeX citation record can be obtained from ADS. See ASCL citing guidelines.

In addition, you should also reference the papers related to the model you use. See the README files of the individual models.

Contributing

I will be happy to include more models if I am given a C implementation of the quantities that are part of the interface.

License

The code is released under the MIT License.

disk-models's People

Contributors

mbursa avatar vvebshare avatar

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.