"\u001b[0;31mAttributeError\u001b[0m: 'tuple' object has no attribute 'default_state'"
]
}
],
...
...
@@ -531,6 +532,41 @@
"field0.discretize(npoints)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
...
...
%% Cell type:markdown id: tags:
# HySoP: Hybrid Simulation with Particles
HySoP is a library dedicated to high performance flow simulation based on particle methods, on hybrid architectures with multiple compute devices including CPUs, GPUs and MICs.
The library is mainly written in Python (high level functionnalities) on the top of Fortran, C++ and OpenCL backends.
## How to use HySoP
The problem to be solved must be described using Python 2.7 language either interactively or in a python script.
If you are not at ease with this language, we strongly encourage you to check one of the numerous python tutorials available on the web. Try for example https://docs.python.org/2/tutorial/. A basic understanding of numpy may also be useful : http://www.numpy.org.
Numpy is the python package for scientific computing on which HySoP relies, especially for arrays handling.
Interactive session is very useful for tests, basic understanding of hysop functionnalities but real simulation must be executed by using a script.
## Quick start
In this quick introduction we will introduce the main data structures of HySoP.
%% Cell type:code id: tags:
``` python
# First we import HySoP and some types we will need for this tutorial
# We will also need Numpy.
importhysop
fromhysopimportBox,Field
importnumpyasnp
```
%% Cell type:markdown id: tags:
### Describing the physical domain
The first thing to do is to create a physical domain where the simulation will take place. At this time the only type of domain available are $n$-dimensional boxes. A box has an origin $X_0=(x_0,\cdots,x_{n-1})$ and a length $L=(L_0, \cdots, L_{n-1})$. By default a unit box will be returned $X_0 = (0,\cdots,0)$ and $L=(1,\cdots,1)$. A domain also provide information about its boundary conditions.
A Box, like many other types in HySoP, has a unique identifier called a tag that identifies any instance of the type uniquely. You can query object tags by using the $tag$ and $full\_tag$ attributes.
%% Cell type:code id: tags:
``` python
print'domain.tag is {}'.format(domain.tag)
print'domain.full_tag is {}.'.format(domain.full_tag)
```
%% Output
domain.tag is d1
domain.full_tag is Box::d1.
%% Cell type:markdown id: tags:
Of course, a Box has many other usefull attributes describing the physical domain:
%% Cell type:code id: tags:
``` python
forattrin('dim','origin','length','periodicity'):
print'domain.{} is {}.'.format(attr,getattr(domain,attr))
```
%% Output
domain.dim is 2.
domain.origin is [0. 0.].
domain.length is [6.28318531 6.28318531].
domain.periodicity is [ True True].
%% Cell type:markdown id: tags:
A full list of attributes along with their documentation can be retrieved by using the python help method:
%% Cell type:code id: tags:
``` python
help(Box)# or help(domain)
```
%% Output
Help on class Box in module hysop.domain.box:
class Box(BoxView, hysop.domain.domain.Domain)
| Box-shaped domain description.
|
| Method resolution order:
| Box
| BoxView
| hysop.domain.domain.DomainView
| hysop.tools.handle.TaggedObjectView
| hysop.domain.domain.Domain
| hysop.tools.handle.RegisteredObject
| hysop.tools.handle.TaggedObject
| __builtin__.object
|
| Methods defined here:
|
| view(self, topology_state)
| Return a view of this domain altered by some topology_state.
| Data descriptors inherited from hysop.tools.handle.RegisteredObject:
|
| obj_initialized
| Return the object initialization state.
%% Cell type:markdown id: tags:
### Creating variables
Now that we have a domain defined, we can define named continuous scalar and vector fields.
In HySoP, a continuous field is an abstract object which represents the usual vector field, in mathematical sense, i.e some function which associates a scalar or a vector to each point of the space.
Such objects are used as input and/or output variables for continuous operators and must be defined with at least:
* a name, compulsory (required for i/o).
* a domain: the physical domain of definition of the field.
The underlying datatype that will be used uppon discretization can also be specified.
By default Fields are set to datatype HYSOP_REAL wich will be either np.float32 (single precision floating point) or np.float64 (double precision floating point) depending on HySoP build configuration. There are no restrictions on the datatypes, for example all integer and complex datatypes can also be specified.
For a domain of dimension $n$, scalar fields $s: \mathbb{R}^n \rightarrow \mathbb{R}$ are defined like this:
Vector fields are created using either the is_vector or the nb_components parameter. is_vector corresponds to specifying nb_components to the number of dimensions of the domain $f(x): \mathbb{R}^n \rightarrow \mathbb{R}^n$ while the more general nb_components parameter allows to specify $g(x): \mathbb{R}^n \rightarrow \mathbb{R}^m$.