QPMS
Electromagnetic multiple scattering library and toolkit.
qpms_types.h
Go to the documentation of this file.
1 
4 #ifndef QPMS_TYPES_H
5 #define QPMS_TYPES_H
6 #include <complex.h>
7 #include <stdbool.h>
8 #include <stddef.h>
9 #include <stdint.h>
10 
11 #ifndef M_PI_2
12 #define M_PI_2 (1.570796326794896619231321691639751442098584699687552910487L)
13 #endif
14 #ifndef M_PI
15 #define M_PI (3.14159265358979323846264338327950288419716939937510582097494L)
16 #endif
17 #ifndef M_SQRT2
18 #define M_SQRT2 (1.41421356237309504880168872420969807856967187537694807317668L)
19 #endif
20 #ifndef M_SQRTPI
21 #define M_SQRTPI (1.77245385090551602729816748334114518279754945612238712821381L)
22 #endif
23 
24 // integer index types
25 typedef int qpms_lm_t;
27 typedef int qpms_l_t; /* can't be unsigned because of the behaviour under the - operator;
28  also -1 needed as an invalid value for scalar waves. */
29 
31 typedef qpms_lm_t qpms_m_t;
32 
34 
44 typedef size_t qpms_y_t;
45 
47 
59 typedef size_t qpms_y_sc_t;
60 
62 typedef enum {
67 
68 // FIXME DOC The references to the functions do not work in doxygen:
70 
81 typedef unsigned long long qpms_uvswfi_t;
82 
84 
85 typedef enum {
87  QPMS_ERROR = -1,
88  QPMS_FAILURE = QPMS_ERROR,
90  QPMS_ESING = 21,
91  QPMS_NAN_ENCOUNTERED = 1024
93 
94 
95 
97 
104 typedef enum {
113 
118 
131  QPMS_NORMALISATION_NORM_BITSTART = 65536,
133 
140  QPMS_NORMALISATION_NORM_POWER = QPMS_NORMALISATION_NORM_BITSTART * 1,
142 
143  QPMS_NORMALISATION_NORM_SPHARM = QPMS_NORMALISATION_NORM_BITSTART * 3,
145 
152  QPMS_NORMALISATION_NORM_NONE = QPMS_NORMALISATION_NORM_BITSTART * 2,
153  QPMS_NORMALISATION_NORM_BITS = QPMS_NORMALISATION_NORM_POWER
155 
169 
172  return (norm & QPMS_NORMALISATION_CSPHASE)? -1 : 1;
173 }
174 
176 typedef enum {
181  QPMS_BESSEL_UNDEF = 0
183 
184 // coordinate system types
186 typedef struct cart3_t {
187  double x, y, z;
189 
191 typedef struct ccart3_t {
192  complex double x, y, z;
194 
196 typedef struct ccart3_pair {
197  ccart3_t E, H;
199 
201 
202 typedef struct cart2_t {
203  double x, y;
205 
207 typedef struct sph_t {
208  double r, theta, phi;
210 
212 typedef struct csph_t { // Do I really need this???
213  complex double r;
214  double theta, phi;
216 
218 typedef struct csphvec_t {
219  complex double rc, thetac, phic;
221 
223 typedef struct pol_t {
224  double r, phi;
226 
228 
229 typedef union anycoord_point_t {
230  double z;
231  cart3_t cart3;
232  cart2_t cart2;
233  sph_t sph;
234  pol_t pol;
236 
238 typedef enum {
239  // IF EVER CHANGING THE CONSTANT VALUES HERE,
240  // CHECK THAT THEY DO NOT CLASH WITH THOSE IN PGenPointFlags!
253 
255 
261 typedef struct qpms_quat_t {
262  complex double a, b;
264 
266 
268 typedef struct qpms_quat4d_t {
269  double c1, ci, cj, ck;
271 
273 
275 typedef struct qpms_irot3_t {
277  short det;
279 
281 
290 typedef struct qpms_vswf_set_spec_t {
291  size_t n;
294 
297 
300 
303 
305  size_t capacity;
308 
310 typedef int32_t qpms_ss_tmi_t;
311 
313 typedef int32_t qpms_ss_tmgi_t;
314 
316 typedef int32_t qpms_ss_pi_t;
317 
318 // These types are mainly used in groups.h:
320 typedef int qpms_gmi_t;
321 
323 typedef int qpms_iri_t;
325 #define QPMS_NO_IRREP ((qpms_iri_t) -1)
326 
328 
330 typedef const char * qpms_permutation_t;
331 
333 
338 typedef struct qpms_tmatrix_t {
347  complex double *m;
348  bool owns_m;
350 
351 
353 typedef enum {
354 
355  // Axial groups
363 
364  // Remaining polyhedral groups
372 
373  // Continuous axial groups
379 
380  // Remaining continuous groups
384 
386 typedef struct qpms_pointgroup_t {
390 
412 
413 
415 typedef struct qpms_abstract_tmatrix_t {
416  const qpms_vswf_set_spec_t *spec;
417  qpms_pointgroup_t sym;
419 
420 
422 typedef struct qpms_epsmu_t {
423  complex double eps;
424  complex double mu;
426 
427 struct qpms_tolerance_spec_t; // See tolerances.h
428 
429 #define lmcheck(l,m) assert((l) >= 1 && abs(m) <= (l))
430 #endif // QPMS_TYPES
int32_t qpms_ss_pi_t
Particle index used in qpms_scatsys_t and related structures.
Definition: qpms_types.h:316
int32_t qpms_ss_tmi_t
T-matrix index used in qpms_scatsys_t and related structures.
Definition: qpms_types.h:310
size_t qpms_y_t
Type for the (l, m) multiindex of transversal (M or N -type) VSWFs.
Definition: qpms_types.h:44
static int qpms_normalisation_t_csphase(qpms_normalisation_t norm)
Determine whether the convention includes Condon-Shortley phase (-1) or not (+1).
Definition: qpms_types.h:171
qpms_normalisation_t
Vector spherical wavefuction normalisation and phase convention codes.
Definition: qpms_types.h:104
@ QPMS_NORMALISATION_NORM_POWER
The VSWFs shall be power-normalised. This is the "default".
Definition: qpms_types.h:140
@ QPMS_NORMALISATION_INVERSE
Flag indicating that qpms_normalisition_factor_* should actually return values inverse to the default...
Definition: qpms_types.h:107
@ QPMS_NORMALISATION_CONVENTION_KRISTENSSON_REAL
VSWF convention used in .
Definition: qpms_types.h:157
@ QPMS_NORMALISATION_SPHARM_REAL
Flag indicating use of the real spherical harmonics.
Definition: qpms_types.h:116
@ QPMS_NORMALISATION_UNDEF
Definition: qpms_types.h:105
@ QPMS_NORMALISATION_L_MINUS
Include an additional -factor into the longitudinal waves.
Definition: qpms_types.h:130
@ QPMS_NORMALISATION_M_I
Include an additional i -factor into the magnetic waves.
Definition: qpms_types.h:125
@ QPMS_NORMALISATION_M_MINUS
Include an additional -factor into the magnetic waves.
Definition: qpms_types.h:126
@ QPMS_NORMALISATION_L_I
Include an additional i -factor into the longitudinal waves.
Definition: qpms_types.h:129
@ QPMS_NORMALISATION_N_MINUS
Include an additional -factor into the magnetic waves.
Definition: qpms_types.h:128
@ QPMS_NORMALISATION_CONVENTION_KRISTENSSON
VSWF convention used in .
Definition: qpms_types.h:160
@ QPMS_NORMALISATION_N_I
Include an additional i -factor into the electric waves.
Definition: qpms_types.h:127
@ QPMS_NORMALISATION_REVERSE_AZIMUTHAL_PHASE
Definition: qpms_types.h:111
@ QPMS_NORMALISATION_DEFAULT
Default VSWF convention. We might encourage the compiler to expect this one.
Definition: qpms_types.h:167
@ QPMS_NORMALISATION_CSPHASE
Flag indicating usage of Condon-Shortley phase.
Definition: qpms_types.h:124
@ QPMS_NORMALISATION_NORM_SPHARM
The VSWFs shall be normalised as in .
Definition: qpms_types.h:143
@ QPMS_NORMALISATION_NORM_NONE
The VSWFs shall be created using spherical harmonics without any normalisation. Do not use.
Definition: qpms_types.h:152
@ QPMS_NORMALISATION_CONVENTION_SCUFF
VSWF convention used in SCUFF-EM .
Definition: qpms_types.h:163
struct csph_t csph_t
Spherical coordinates with complex radial component. See also vectors.h.
struct sph_t sph_t
Spherical coordinates. See also vectors.h.
int qpms_l_t
Type for spherical harmonic degree l.
Definition: qpms_types.h:27
struct qpms_quat4d_t qpms_quat4d_t
Quaternion type as four doubles.
qpms_coord_system_t
Enum codes for common coordinate systems.
Definition: qpms_types.h:238
@ QPMS_COORDS_CART2
2D cartesian.
Definition: qpms_types.h:244
@ QPMS_COORDS_CART3
Definition: qpms_types.h:245
@ QPMS_COORDS_BITRANGE
Convenience bitmask (not a valid flag!).
Definition: qpms_types.h:247
@ QPMS_COORDS_CART1
1D cartesian (= double).
Definition: qpms_types.h:241
@ QPMS_COORDS_SPH
3D spherical.
Definition: qpms_types.h:243
@ QPMS_COORDS_POL
2D polar.
Definition: qpms_types.h:242
struct cart2_t cart2_t
2D cartesian coordinates. See also vectors.h.
struct ccart3_pair ccart3_pair
3D complex vector pair (represents the E, H fields).
qpms_vswf_type_t
Codes of the VSWF types (electric/N, magnetic/M, longitudinal/L).
Definition: qpms_types.h:62
@ QPMS_VSWF_ELECTRIC
"Electric" (N -type) transversal wave.
Definition: qpms_types.h:63
@ QPMS_VSWF_LONGITUDINAL
Longitudinal (L -type) wave (not relevant for radiation).
Definition: qpms_types.h:65
@ QPMS_VSWF_MAGNETIC
"Magnetic" (M -type) transversal wave.
Definition: qpms_types.h:64
int32_t qpms_ss_tmgi_t
T-matrix generator index used in qpms_scatsys_t and related structures.
Definition: qpms_types.h:313
struct qpms_tmatrix_t qpms_tmatrix_t
A T-matrix.
struct pol_t pol_t
2D polar coordinates. See also vectors.h.
struct qpms_quat_t qpms_quat_t
Quaternion type.
int qpms_gmi_t
Finite group member index. See also groups.h.
Definition: qpms_types.h:320
unsigned long long qpms_uvswfi_t
Exhaustive index type for VSWF basis functions.
Definition: qpms_types.h:81
struct csphvec_t csphvec_t
3D complex vector components in local spherical basis. See also vectors.h.
size_t qpms_y_sc_t
Type for the (l, m) multiindex of spherical harmonics, including (0, 0).
Definition: qpms_types.h:59
qpms_errno_t
Error codes / return values for certain numerical functions.
Definition: qpms_types.h:85
@ QPMS_ERROR
Unspecified error.
Definition: qpms_types.h:87
@ QPMS_ENOMEM
Out of memory.
Definition: qpms_types.h:89
@ QPMS_NAN_ENCOUNTERED
NaN value encountered in data processing.
Definition: qpms_types.h:91
@ QPMS_SUCCESS
Success.
Definition: qpms_types.h:86
@ QPMS_ESING
Apparent singularity detected.
Definition: qpms_types.h:90
union anycoord_point_t anycoord_point_t
Union type capable to contain various 1D, 2D and 3D coordinates.
struct qpms_irot3_t qpms_irot3_t
3D improper rotations represented as a quaternion and a sign of the determinant.
int qpms_iri_t
Irreducible representation index. See also groups.h.
Definition: qpms_types.h:323
struct qpms_vswf_set_spec_t qpms_vswf_set_spec_t
Specifies a finite set of VSWFs.
struct qpms_abstract_tmatrix_t qpms_abstract_tmatrix_t
An abstract T-matrix without actual elements, but with info about particle symmetry.
struct qpms_pointgroup_t qpms_pointgroup_t
Full characterisation of a 3D point group.
const char * qpms_permutation_t
Permutation representation of a group element.
Definition: qpms_types.h:330
qpms_pointgroup_class
Classification of a 3D point group.
Definition: qpms_types.h:353
@ QPMS_PGS_I
Chiral icosahedral symmetry .
Definition: qpms_types.h:370
@ QPMS_PGS_OH
Full octahedral symmetry .
Definition: qpms_types.h:369
@ QPMS_PGS_CINF
Definition: qpms_types.h:374
@ QPMS_PGS_CINFV
Definition: qpms_types.h:376
@ QPMS_PGS_IH
Full icosahedral symmetry .
Definition: qpms_types.h:371
@ QPMS_PGS_DND
Antiprismatic symmetry .
Definition: qpms_types.h:361
@ QPMS_PGS_DN
Dihedral symmetry .
Definition: qpms_types.h:360
@ QPMS_PGS_O3
Orthogonal group.
Definition: qpms_types.h:382
@ QPMS_PGS_SO3
Special orthogonal group.
Definition: qpms_types.h:381
@ QPMS_PGS_TD
Full tetrahedral symmetry .
Definition: qpms_types.h:366
@ QPMS_PGS_CN
Rotational symmetry .
Definition: qpms_types.h:356
@ QPMS_PGS_S2N
Rotoreflectional symmetry .
Definition: qpms_types.h:357
@ QPMS_PGS_TH
Pyritohedral symmetry .
Definition: qpms_types.h:367
@ QPMS_PGS_T
Chiral tetrahedral symmetry .
Definition: qpms_types.h:365
@ QPMS_PGS_CINFH
Definition: qpms_types.h:375
@ QPMS_PGS_DINFH
Definition: qpms_types.h:378
@ QPMS_PGS_CNV
Pyramidal symmetry .
Definition: qpms_types.h:359
@ QPMS_PGS_DINF
Definition: qpms_types.h:377
@ QPMS_PGS_DNH
Prismatic symmetry .
Definition: qpms_types.h:362
@ QPMS_PGS_O
Chiral octahedral symmetry .
Definition: qpms_types.h:368
@ QPMS_PGS_CNH
Rotational symmetry with horizontal reflection .
Definition: qpms_types.h:358
struct qpms_epsmu_t qpms_epsmu_t
A type holding electric permittivity and magnetic permeability of a material.
qpms_bessel_t
Bessel function kinds.
Definition: qpms_types.h:176
@ QPMS_BESSEL_UNDEF
invalid / unspecified kind
Definition: qpms_types.h:181
@ QPMS_BESSEL_REGULAR
regular (spherical) Bessel function j (Bessel function of the first kind)
Definition: qpms_types.h:177
@ QPMS_HANKEL_MINUS
(spherical) Hankel function
Definition: qpms_types.h:180
@ QPMS_BESSEL_SINGULAR
singular (spherical) Bessel function y (Bessel function of the second kind)
Definition: qpms_types.h:178
@ QPMS_HANKEL_PLUS
(spherical) Hankel function
Definition: qpms_types.h:179
qpms_lm_t qpms_m_t
Type for spherical harmonic order m.
Definition: qpms_types.h:31
struct ccart3_t ccart3_t
3D complex (actually 6D) coordinates. See also vectors.h.
struct cart3_t cart3_t
3D cartesian coordinates. See also vectors.h.
2D cartesian coordinates. See also vectors.h.
Definition: qpms_types.h:202
3D cartesian coordinates. See also vectors.h.
Definition: qpms_types.h:186
3D complex vector pair (represents the E, H fields).
Definition: qpms_types.h:196
3D complex (actually 6D) coordinates. See also vectors.h.
Definition: qpms_types.h:191
Spherical coordinates with complex radial component. See also vectors.h.
Definition: qpms_types.h:212
3D complex vector components in local spherical basis. See also vectors.h.
Definition: qpms_types.h:218
2D polar coordinates. See also vectors.h.
Definition: qpms_types.h:223
An abstract T-matrix without actual elements, but with info about particle symmetry.
Definition: qpms_types.h:415
A type holding electric permittivity and magnetic permeability of a material.
Definition: qpms_types.h:422
complex double mu
Relative permeability.
Definition: qpms_types.h:424
complex double eps
Relative permittivity.
Definition: qpms_types.h:423
3D improper rotations represented as a quaternion and a sign of the determinant.
Definition: qpms_types.h:275
short det
Determinant of the transformation (valid values are 1 (rotation) or -1 (improper rotation)
Definition: qpms_types.h:277
qpms_quat_t rot
Quaternion representing the rotation part.
Definition: qpms_types.h:276
Full characterisation of a 3D point group.
Definition: qpms_types.h:386
qpms_pointgroup_class c
Point group classification.
Definition: qpms_types.h:387
qpms_irot3_t orientation
Transformation between this point group and the "canonical" point group of the same type.
Definition: qpms_types.h:410
qpms_gmi_t n
Definition: qpms_types.h:388
Quaternion type as four doubles.
Definition: qpms_types.h:268
Quaternion type.
Definition: qpms_types.h:261
A T-matrix.
Definition: qpms_types.h:338
bool owns_m
Information wheter m shall be deallocated with qpms_tmatrix_free()
Definition: qpms_types.h:348
const qpms_vswf_set_spec_t * spec
VSWF basis specification, NOT owned by qpms_tmatrix_t by default.
Definition: qpms_types.h:346
complex double * m
Matrix elements in row-major order.
Definition: qpms_types.h:347
Definition: tolerances.h:7
Specifies a finite set of VSWFs.
Definition: qpms_types.h:290
qpms_l_t lMax_N
Maximum degree of the electric (N-type) waves.
Definition: qpms_types.h:301
size_t capacity
Allocated capacity of ilist.
Definition: qpms_types.h:305
size_t n
Actual number of VSWF indices included in ilist.
Definition: qpms_types.h:291
qpms_uvswfi_t * ilist
Definition: qpms_types.h:292
qpms_normalisation_t norm
Normalisation convention. To be set manually if needed.
Definition: qpms_types.h:306
qpms_l_t lMax_M
Maximum degree of the magnetic (M-type) waves.
Definition: qpms_types.h:298
qpms_l_t lMax_L
Maximum degree of the longitudinal (L-type) waves.
Definition: qpms_types.h:304
qpms_l_t lMax
Maximum degree of the waves specified in ilist overall.
Definition: qpms_types.h:295
Spherical coordinates. See also vectors.h.
Definition: qpms_types.h:207
Union type capable to contain various 1D, 2D and 3D coordinates.
Definition: qpms_types.h:229
double z
1D cartesian coordinate.
Definition: qpms_types.h:230