Two dimensional model of propagating blobs
Project description
2d_propagating_blobs
Two dimensional model of advecting and dissipating blobs.
The code has been deveoped originally to model profiles in the scrape-off layer of fusion experiments but it can be used to model any 2d system consisting of advecting pulses. An example is shown below:
Installation
Dev install:
git clone https://github.com/uit-cosmo/2d_propagating_blobs.git
cd 2d_propagating_blobs
pip install -e .
Usage
Create the grid on which the blobs are discretized with using the Model
class. The make_realization()
method computes the output as an xarray dataset which can also be written out as a netcdf
file if the argument file_name
is specified. A simple example is shown below:
from blobmodel import Model, show_model
bm = Model(Nx=200, Ny=100, Lx=10, Ly=10, dt=0.1, T=20, blob_shape='gauss',num_blobs=100)
ds = bm.make_realization(file_name="example.nc")
The data can be shown as an animation using the show_model
function:
show_model(ds)
You can specify the blob parameters with a BlobFactory class. The DefaultBlobFactory class has some of the most common distribution functions implemented. An example would look like this:
from blobmodel import Model, DefaultBlobFactory
# use DefaultBlobFactory to define distribution functions fo random variables
bf = DefaultBlobFactory(A_dist="exp", W_dist="uniform", vx_dist="deg", vy_dist="normal")
# pass on bf when creating the Model
tmp = Model(
Nx=100,
Ny=1,
Lx=10,
Ly=0,
dt=1,
T=1000,
blob_shape="exp",
t_drain=2,
periodic_y=False,
num_blobs=10000,
blob_factory=bf,
)
Alternatively, you can specify all blob parameters exactly as you want by writing your own class which inherits from BlobFactory. See examples/custom_blobfactory.py
as an example.
Input parameters
Model()
Nx
: int, grid points in xNy
: int, grid points in yLx
: float, length of grid in xLy
: float, length of grid in ydt
: float, time stepT
: float, time lengthperiodic_y
: bool, optional, allow periodicity in y-directionblob_shape
: str, optional, switch betweengauss
andexp
blobnum_blobs
: int, optional number of blobst_drain
: float, optional, drain time for blobsblob_factory
: BlobFactory, optional, object containing blob parameterslabels
: bool, optional, if True, field with blob labels is returned used for creating training data for supervised machine learning algorithmslabel_border
: float, optional, defines region of blob as region where density >= label_border * amplitude of Blob only used if labels = True
DefaultBlobFactory()
A_dist
: str, optional, distribution of blob amplitudesW_dist
: str, optional, distribution of blob widthsvx_dist
: str, optinal, distribution of blob velocities in x-dimensionvy_dist
: str, optinal, distribution of blob velocities in y-dimensionA_parameter
: float, optional,free_parameter
for amplitudesW_parameter
: float, optional,free_parameter
for widthsvx_parameter
: float, optional,free_parameter
for vxvy_parameter
: float, optional,free_parameter
for vy
The following distributions are implemented:
exp
: exponential distribution with mean 1gamma
: gamma distribution withfree_parameter
as shape parameter and mean 1normal
: normal distribution with zero mean andfree_parameter
as scale parameteruniform
: uniorm distribution with mean 1 andfree_parameter
as widthray
: rayleight distribution with mean 1deg
: array on oneszeros
: array of zeros
make_realization()
-
file_name
: str, optional, file name for .nc file containing data as xarray dataset -
speed_up
: bool, optional, speeding up code by discretizing each single blob at smaller time window when blob values fall under given error value the blob gets discarded!!! this is only a good approximation for blob_shape='exp' !!!
-
error
: float, optional, numerical error at x = Lx when blob gets truncated
show_model()
ds
: xarray Dataset, Model datainterval
: int, optional, time interval between frames in mssave
: bool, optional, if True save animation as gifgif_name
: str, optional, set name for giffps
: int, optional, set fps for gif
Contact
If you have questions, suggestions or other comments you can contact me under gregor.decristoforo@uit.no
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
Hashes for blobmodel-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c109a0f9c4aa4dc02b095b992a3f1d95eb8304bf208af1149815d1a01218e157 |
|
MD5 | d83ac41b59cefb0d657a33c85efd0a16 |
|
BLAKE2b-256 | 41a42d26d5585ff563a10b34e4207af47a61609f7c7f16b1c2ee689730aaba11 |