aboutsummaryrefslogtreecommitdiff
path: root/brill_data.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2015-04-14 16:00:24 +0200
committerAnton Khirnov <anton@khirnov.net>2015-04-14 16:02:58 +0200
commit41f29cbf3076db51b96f240d27d432ef31b8aa71 (patch)
treeaedc8f140385f4c94054b561e09358a04ffbc296 /brill_data.py
parent307d35ed2bc4e073ae3a6ceac3dcb7a74f25e98a (diff)
A major rewrite.
Split the code into multiple files, drop the GSL dependency, introduce configurable logging, random cleanups.
Diffstat (limited to 'brill_data.py')
-rw-r--r--brill_data.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/brill_data.py b/brill_data.py
index 26c8efb..398a8d8 100644
--- a/brill_data.py
+++ b/brill_data.py
@@ -20,6 +20,15 @@ import brill_data
import ctypes
import numpy as np
+BD_METRIC_COMPONENT_RHORHO = 0
+BD_METRIC_COMPONENT_RHOZ = 1
+BD_METRIC_COMPONENT_RHOPHI = 2
+BD_METRIC_COMPONENT_ZRHO = 3
+BD_METRIC_COMPONENT_ZZ = 4
+BD_METRIC_COMPONENT_ZPHI = 5
+BD_METRIC_COMPONENT_PHIRHO = 6
+BD_METRIC_COMPONENT_PHIZ = 7
+BD_METRIC_COMPONENT_PHIPHI = 8
class BrillData(object):
@@ -37,10 +46,10 @@ class BrillData(object):
("nb_coeffs_z", ctypes.c_uint),
("overdet_rho", ctypes.c_int),
("overdet_z", ctypes.c_int),
- ("colloc_grid_offset_rho", ctypes.c_uint),
- ("colloc_grid_offset_z", ctypes.c_uint),
("basis_scale_factor_rho", ctypes.c_double),
("basis_scale_factor_z", ctypes.c_double),
+ ("log_callback", ctypes.c_void_p),
+ ("opaque", ctypes.c_void_p),
("psi_minus1_coeffs", ctypes.POINTER(ctypes.c_double)),
("stride", ctypes.c_long)]
@@ -54,7 +63,7 @@ class BrillData(object):
if ret < 0:
raise RuntimeError('Error solving the equation')
- self.coeffs = np.copy(np.ctypeslib.as_array(self._bdctx.contents.psi_minus1_coeffs, (self._bdctx.contents.nb_coeffs_rho, self._bdctx.contents.nb_coeffs_z)))
+ self.coeffs = np.copy(np.ctypeslib.as_array(self._bdctx.contents.psi_minus1_coeffs, (self._bdctx.contents.nb_coeffs_z, self._bdctx.contents.nb_coeffs_rho)))
def __del__(self):
if self._bdctx:
@@ -80,7 +89,7 @@ class BrillData(object):
c_z = np.ctypeslib.as_ctypes(z)
ret = self._libbd.bd_eval_psi(self._bdctx, c_rho, len(c_rho),
- c_z, len(c_z), c_diff_order, c_psi)
+ c_z, len(c_z), c_diff_order, c_psi, len(c_rho))
if ret < 0:
raise RuntimeError('Error evaluating psi')
@@ -97,18 +106,22 @@ class BrillData(object):
c_diff_order[0] = diff_order[0]
c_diff_order[1] = diff_order[1]
- c_component = (ctypes.c_uint * 2)()
- c_component[0] = component[0]
- c_component[1] = component[1]
+ c_component = (ctypes.c_uint * 1)()
+ c_component[0] = component
- metric = np.empty((z.shape[0], rho.shape[0]))
-
- c_metric = np.ctypeslib.as_ctypes(metric)
c_rho = np.ctypeslib.as_ctypes(rho)
c_z = np.ctypeslib.as_ctypes(z)
+ metric = np.empty((z.shape[0], rho.shape[0]))
+
+ c_metric = (ctypes.POINTER(ctypes.c_double) * 1)()
+ c_metric[0] = ctypes.cast(np.ctypeslib.as_ctypes(metric), type(c_metric[0]))
+
+ c_metric_strides = (ctypes.c_uint * 1)()
+ c_metric_strides[0] = len(c_rho)
+
ret = self._libbd.bd_eval_metric(self._bdctx, c_rho, len(c_rho),
- c_z, len(c_z), c_component, c_diff_order, c_metric)
+ c_z, len(c_z), 1, c_component, c_diff_order, c_metric, c_metric_strides)
if ret < 0:
raise RuntimeError('Error evaluating the metric')
@@ -132,7 +145,7 @@ class BrillData(object):
c_z = np.ctypeslib.as_ctypes(z)
ret = self._libbd.bd_eval_q(self._bdctx, c_rho, len(c_rho),
- c_z, len(c_z), c_diff_order, c_q)
+ c_z, len(c_z), c_diff_order, c_q, len(c_rho))
if ret < 0:
raise RuntimeError('Error evaluating q')