Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release 1.6.0 (TBD)
-------------------

New:
* Add Function6D framework. (#478)
* Add e_field attribute to Plasma object for electric field vector. (#465)
* Add Integrator2D base class for integration of two-dimensional functions. (#472)

Expand Down
1 change: 1 addition & 0 deletions cherab/core/math/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@
from .transform import CylindricalTransform, VectorCylindricalTransform
from .transform import PeriodicTransform1D, PeriodicTransform2D, PeriodicTransform3D
from .transform import VectorPeriodicTransform1D, VectorPeriodicTransform2D, VectorPeriodicTransform3D
from .function import *
2 changes: 2 additions & 0 deletions cherab/core/math/function/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.core.math.function cimport float

from raysect.core.math.function.float cimport Function1D, autowrap_function1d
from raysect.core.math.function.float cimport Function2D, autowrap_function2d
from raysect.core.math.function.float cimport Function3D, autowrap_function3d
Expand Down
2 changes: 2 additions & 0 deletions cherab/core/math/function/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from . import float

from raysect.core.math.function.float import Function1D, Function2D, Function3D
from raysect.core.math.function.float import Constant1D, Constant2D, Constant3D
from raysect.core.math.function.float import Discrete2DMesh, Interpolator2DMesh
Expand Down
32 changes: 32 additions & 0 deletions cherab/core/math/function/float/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# cython: language_level=3

# Copyright (c) 2014-2023, Dr Alex Meakins, Raysect Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Raysect Project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from cherab.core.math.function.float.function6d cimport *
32 changes: 32 additions & 0 deletions cherab/core/math/function/float/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# cython: language_level=3

# Copyright (c) 2014-2023, Dr Alex Meakins, Raysect Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Raysect Project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from .function6d import *
37 changes: 37 additions & 0 deletions cherab/core/math/function/float/function6d/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# cython: language_level=3

# Copyright (c) 2014-2023, Dr Alex Meakins, Raysect Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Raysect Project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from cherab.core.math.function.float.function6d.base cimport Function6D
from cherab.core.math.function.float.function6d.constant cimport Constant6D
from cherab.core.math.function.float.function6d.blend cimport Blend6D
from cherab.core.math.function.float.function6d.autowrap cimport autowrap_function6d
from cherab.core.math.function.float.function6d.arg cimport Arg6D
from cherab.core.math.function.float.function6d.cmath cimport *
36 changes: 36 additions & 0 deletions cherab/core/math/function/float/function6d/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# cython: language_level=3

# Copyright (c) 2014-2023, Dr Alex Meakins, Raysect Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Raysect Project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from .base import Function6D
from .constant import Constant6D
from .blend import Blend6D
from .arg import Arg6D
from .cmath import *
27 changes: 27 additions & 0 deletions cherab/core/math/function/float/function6d/arg.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# cython: language_level=3

# Copyright 2016-2025 Euratom
# Copyright 2016-2025 United Kingdom Atomic Energy Authority
# Copyright 2016-2025 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.core.math.function.float.function6d.base cimport Function6D

cdef enum ArgLabel:
X, Y, Z, U, W, V

cdef class Arg6D(Function6D):
cdef ArgLabel _argument
82 changes: 82 additions & 0 deletions cherab/core/math/function/float/function6d/arg.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# cython: language_level=3

# Copyright 2016-2025 Euratom
# Copyright 2016-2025 United Kingdom Atomic Energy Authority
# Copyright 2016-2025 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.core.math.function.float.function6d.base cimport Function6D


cdef class Arg6D(Function6D):
"""
Returns one of the arguments the function is passed, unmodified

This is used to pass coordinates through to other functions in the
function framework which expect a Function6D object.

Valid options for argument are "x", "y", "z", "u", "w", or "v".

>>> argx = Arg6D("x")
>>> argx(2, 3, 5, 7, 11, 13)
2.0
>>> argy = Arg6D("y")
>>> argy(2, 3, 5, 7, 11, 13)
3.0
>>> argz = Arg6D("z")
>>> argz(2, 3, 5, 7, 11, 13)
5.0
>>> argu = Arg6D("u")
>>> argu(2, 3, 5, 7, 11, 13)
7.0
>>> argw = Arg6D("w")
>>> argw(2, 3, 5, 7, 11, 13)
11.0
>>> argv = Arg6D("v")
>>> argv(2, 3, 5, 7, 11, 13)
13.0

:param str argument: either "x", "y", "z", "u", "w", or "v", the argument to return
"""
def __init__(self, object argument):
if argument == "x":
self._argument = X
elif argument == "y":
self._argument = Y
elif argument == "z":
self._argument = Z
elif argument == "u":
self._argument = U
elif argument == "w":
self._argument = W
elif argument == "v":
self._argument = V
else:
raise ValueError("The argument to Arg6D must be either 'x', 'y', 'z', 'u', 'w' or 'v'")

cdef double evaluate(self, double x, double y, double z, double u, double w, double v) except? -1e999:
if self._argument == X:
return x
elif self._argument == Y:
return y
elif self._argument == Z:
return z
elif self._argument == U:
return u
elif self._argument == W:
return w
else: # V
return v
26 changes: 26 additions & 0 deletions cherab/core/math/function/float/function6d/autowrap.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# cython: language_level=3

# Copyright 2016-2025 Euratom
# Copyright 2016-2025 United Kingdom Atomic Energy Authority
# Copyright 2016-2025 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.core.math.function.float.function6d.base cimport Function6D

cdef class PythonFunction6D(Function6D):
cdef public object function

cdef Function6D autowrap_function6d(object obj)
Loading