Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and improvements in SOLPSSimulation, SOLPSMesh and related functions #35

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d428e5b
Removed _popular_species and _species_symbol_map dicts, added setters…
vsnever Sep 4, 2020
9006823
Added ion and nuetral atom temperatures.
vsnever Sep 4, 2020
1e41cd4
Many fixes and improvements in SOLPSMesh class
vsnever Sep 5, 2020
687e991
Corrected mesh basis vector calculation
vsnever Sep 6, 2020
5dcc0dd
Added poloidal <--> Cartesian conversion to SOLPSMesh. Added conversi…
vsnever Sep 6, 2020
bdf99da
Replaced nested loops in _map_data_onto_triangles with vector code.
vsnever Sep 6, 2020
800b878
Added magnetic files, velocity and neutral temperature reading to raw…
vsnever Sep 6, 2020
9b0e9c1
Added exception handling to load_solps_from_mdsplus() for better supp…
vsnever Sep 7, 2020
b840d3f
Renamed parallel direction to poloidal in SOLPSMesh to match SOLPS no…
vsnever Sep 7, 2020
8a082e7
Added fluxes to velocity conversion to adress #36.
vsnever Sep 8, 2020
df6ad34
Removed modification of assigned SOLPSSimulation attributes to simpli…
vsnever Sep 8, 2020
9ce89bb
Added set_..() and get_..() interfaces to SOLPSSimulation to make eas…
vsnever Sep 9, 2020
52a5162
Made assign_fort44_parser() less strict to adress #32
vsnever Sep 9, 2020
48445d9
Fixed errors with pickle save/load.
vsnever Sep 9, 2020
1e55144
Corrected the typo
vsnever Sep 10, 2020
1884289
Made all array row-major and inverted indexing. Removed get_*(), set_…
vsnever Sep 10, 2020
8953c54
Implemented SOLPSFunction2D and SOLPSVectorFunction2D, added *_f2d() …
vsnever Sep 10, 2020
9b31601
Updated __getstate__, __setstate__ in SOLPSSimulation.
vsnever Sep 11, 2020
042812f
Properly distinguished poloidal (poloidal, radial, toroidal), cylindr…
vsnever Sep 11, 2020
f153221
Added docstrings to new SOLPSSimulation attributes and some safety ch…
vsnever Sep 11, 2020
a7b890a
Fixed a typo
vsnever Sep 11, 2020
b9819de
Moved b2_flux_to_velocity() and eirene_flux_to_velocity() to SOLPSSim…
vsnever Sep 12, 2020
1a0b412
eirene.elosm and eirene.edism now resolved over molecules like in for…
vsnever Sep 15, 2020
1c2a22f
Updated balance.py to match the functionality of mdsplus.py.
vsnever Sep 15, 2020
a7202e4
Fixes in response to reviewers comments. Removed redundant check for …
vsnever Sep 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
jacklovell marked this conversation as resolved.
Show resolved Hide resolved
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