Skip to content

Commit

Permalink
Merge pull request #38 from cherab/maintenance/raysect-imports
Browse files Browse the repository at this point in the history
Maintenance/raysect imports
  • Loading branch information
jacklovell authored Sep 22, 2020
2 parents f77a190 + 187be3d commit 6999c77
Show file tree
Hide file tree
Showing 18 changed files with 1,569 additions and 947 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Project Changelog
=================

Release 1.2.0 (19 Sept 2020)
----------------------------

* Added support for Raysect 0.7.
* Replaced unsafe SOLPSFunction3D and SOLPSVectorFunction3D with safe SOLPSFunction2D and SOLPSVectorFunction2D (use AxisymmetricMapper(SOLPSFunction2D) and VectorAxisymmetricMapper(SOLPSVectorFunction2D) for 3D).
* Added correct initialisation of properties in SOLPSMesh and SOLPSSimulation.
* Added new attributes to SOLPSMesh for basis vectors, cell connection areas, indices of neighbouring cells and new methods to_poloidal() and to_cartesian() for converting vectors defined on a grid from/to (poloidal, radial)/(R, Z).
* Fixed incorrect calculation of cell basis vectors.
* Inverted the indexing of data arrays and made all arrays row-major.
* Added electron_velocities and neutral_listproperties to SOLPSSimulation.
* Added 2D and 3D interpolators for plasma parameters to SOLPSSimulation.
* Added parsing of additional quantities in load_solps_from_mdsplus(), load_solps_from_raw_output() and load_solps_from_balance().
* Added support for B2 stand-alone simulations.
* Added support for arbitrary plasma chemical composition.
* Fixed incorrect calculation of velocities.
* Other small fixes and improvements.

Release 1.1.0 (30 July 2020)
----------------------------

Expand Down
2 changes: 1 addition & 1 deletion cherab/solps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from .solps_3d_functions import SOLPSFunction3D, SOLPSVectorFunction3D
from .solps_2d_functions import SOLPSFunction2D, SOLPSVectorFunction2D
from .mesh_geometry import SOLPSMesh
from .solps_plasma import SOLPSSimulation
from .formats import load_solps_from_raw_output, load_solps_from_mdsplus, load_solps_from_balance
8 changes: 4 additions & 4 deletions cherab/solps/b2/parse_b2_block_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ def _make_solps_data_object(_data):

# Multiple 2D data field (e.g. na)
if number > nxyg:
_data = np.array(_data).reshape((nxg, nyg, int(number / nxyg)), order='F')
_data = np.array(_data).reshape((number // nxyg, nyg, nxg))
if debug:
print('Mesh data field {} with dimensions: {:d} x {:d} x {:d}'.format(name, nxg, nyg, int(number/nxyg)))
print('Mesh data field {} with dimensions: {:d} x {:d} x {:d}'.format(name, number // nxyg, nyg, nxg))
return MESH_DATA, _data

# 2D data field (e.g. ne)
elif number == nxyg:
_data = np.array(_data).reshape((nxg, nyg), order='F')
_data = np.array(_data).reshape((nyg, nxg))
if debug:
print('Mesh data field {} with dimensions: {:d} x {:d}'.format(name, nxg, nyg))
print('Mesh data field {} with dimensions: {:d} x {:d}'.format(name, nyg, nxg))
return MESH_DATA, _data

# Additional information field (e.g. zamin)
Expand Down
18 changes: 8 additions & 10 deletions cherab/solps/eirene/eirene.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

import numpy as np


# Code based on script by Felix Reimold (2016)
class Eirene:
Expand Down Expand Up @@ -91,7 +89,7 @@ def __init__(self, nx, ny, na, nm, ni, ns, species_labels, version=None,
@property
def nx(self):
"""
Number of grid cells in the x direction
Number of grid cells in the poloidal direction
:rtype: int
"""
Expand All @@ -100,7 +98,7 @@ def nx(self):
@property
def ny(self):
"""
Number of grid cells in the y direction
Number of grid cells in the radial direction
:rtype: int
"""
Expand Down Expand Up @@ -395,7 +393,7 @@ def elosm(self):

@elosm.setter
def elosm(self, value):
self._check_dimensions(value, 1)
self._check_dimensions(value, self._nm)
self._elosm = value

@property
Expand All @@ -409,7 +407,7 @@ def edism(self):

@edism.setter
def edism(self, value):
self._check_dimensions(value, 1)
self._check_dimensions(value, self._nm)
self._edism = value

@property
Expand All @@ -426,13 +424,13 @@ def eradt(self, value):
self._check_dimensions(value, 1)
self._eradt = value

def _check_dimensions(self, data, dim2):
def _check_dimensions(self, data, dim0):
"""
Checks compatibility of the data array dimension with the species number and grid size.
:param dim2: size of the 2nd dimenion
:param dim0: size of the 1st dimenion
:return:
"""

if not data.shape == (self._nx, self._ny, dim2):
if not data.shape == (dim0, self._ny, self._nx):
raise ValueError("Array with shape {0} obtained, but {1} expected".format(data.shape,
(self._nx, self._ny, dim2)))
(dim0, self._ny, self._nx)))
2 changes: 1 addition & 1 deletion cherab/solps/eirene/parser/fort44.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def load_fort44_file(file_path, debug=False):

# Look up file parsing function and call it to obtain for44 block and update data dictionary
parser = assign_fort44_parser(data["version"])
return parser(file_path)
return parser(file_path, debug)


def assign_fort44_parser(file_version):
Expand Down
4 changes: 2 additions & 2 deletions cherab/solps/eirene/parser/fort44_2013.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def load_fort44_2013(file_path, debug=False):
eirene.emism = read_block44(file_handle, 1, nx, ny) # Molecular Halpha Emission

# Radiated power (elosm, edism, eradt)
eirene.elosm = read_block44(file_handle, 1, nx, ny) # Power loss due to molecules (including dissociation)
eirene.edism = read_block44(file_handle, 1, nx, ny) # Power loss due to molecule dissociation
eirene.elosm = read_block44(file_handle, nm, nx, ny) # Power loss due to molecules (including dissociation)
eirene.edism = read_block44(file_handle, nm, nx, ny) # Power loss due to molecule dissociation
eirene.eradt = read_block44(file_handle, 1, nx, ny) # Neutral radiated power

return eirene
2 changes: 1 addition & 1 deletion cherab/solps/eirene/parser/fort44_2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def load_fort44_2017(file_path, debug=False):
_ = read_block44(file_handle, eirene.nm, eirene.nx, eirene.ny) # Molecule particle source

# Radiated power (elosm, edism, eradt)
eirene.edism = read_block44(file_handle, 1, eirene.nx, eirene.ny) # Power loss due to molecule dissociation
eirene.edism = read_block44(file_handle, eirene.nm, eirene.nx, eirene.ny) # Power loss due to molecule dissociation

# Consume lines until eradt is reached
while True:
Expand Down
8 changes: 4 additions & 4 deletions cherab/solps/eirene/parser/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def read_block44(file_handle, ns, nx, ny):
:param file_handle: A python core file handle object as a result of a
call to open('./fort.44').
:param int ns: total number of species
:param int nx: number of grid x cells
:param int ny: number of grid y cells
:return: ndarray of data with shape [nx, ny, ns]
:param int nx: number of grid poloidal cells
:param int ny: number of grid radial cells
:return: ndarray of data with shape [ns, ny, nx]
"""
data = []
npoints = ns * nx * ny
Expand All @@ -37,5 +37,5 @@ def read_block44(file_handle, ns, nx, ny):
# This is a comment line. Ignore
continue
data.extend(line)
data = np.asarray(data, dtype=float).reshape((nx, ny, ns), order='F')
data = np.asarray(data, dtype=float).reshape((ns, ny, nx))
return data
Loading

0 comments on commit 6999c77

Please sign in to comment.