WIP scatsystem update for "abstract" T-matrices.

Former-commit-id: 7f723a0f459f263e12282edfb1e8deb440650880
This commit is contained in:
Marek Nečada 2020-01-07 16:57:59 +02:00
parent c2b4787cd5
commit d31d8737b8
4 changed files with 51 additions and 17 deletions

View File

@ -297,6 +297,9 @@ typedef struct qpms_vswf_set_spec_t {
/// T-matrix index used in qpms_scatsys_t and related structures. /// T-matrix index used in qpms_scatsys_t and related structures.
typedef int32_t qpms_ss_tmi_t; typedef int32_t qpms_ss_tmi_t;
/// T-matrix generator index used in qpms_scatsys_t and related structures.
typedef int32_t qpms_ss_tmgi_t;
/// Particle index used in qpms_scatsys_t and related structures. /// Particle index used in qpms_scatsys_t and related structures.
typedef int32_t qpms_ss_pi_t; typedef int32_t qpms_ss_pi_t;

View File

@ -121,14 +121,32 @@ typedef struct qpms_ss_particle_orbitinfo {
qpms_ss_orbit_pi_t p; ///< Order (sija, ei rankki) of the particle inside that orbit type. qpms_ss_orbit_pi_t p; ///< Order (sija, ei rankki) of the particle inside that orbit type.
} qpms_ss_particle_orbitinfo_t; } qpms_ss_particle_orbitinfo_t;
/// Auxillary type used in qpms_scatsys_t: A recepy to create another T-matrices by symmetry operations.
typedef struct qpms_ss_derived_tmatrix {
qpms_ss_tmgi_t tmgi; ///< Index of the corresponding qpms_scatsys_t::tm element.
qpms_tmatrix_operation_t *op; ///< Operation to derive this particular T-matrix.
} qpms_ss_derived_tmatrix_t;
struct qpms_trans_calculator; struct qpms_trans_calculator;
struct qpms_epsmu_generator_t; struct qpms_epsmu_generator_t;
typedef struct qpms_scatsys_t { typedef struct qpms_scatsys_t {
struct qpms_qpms_epsmu_generator_t *medium; ///< Optical properties of the background medium. struct qpms_qpms_epsmu_generator_t *medium; ///< Optical properties of the background medium.
qpms_abstract_tmatrix_t **tm; ///< T-matrices in the system
qpms_ss_tmi_t tm_count; ///< Number of all different T-matrices /// (Template) T-matrix functions in the system.
/** The qpms_abstract_tmatrix_t objects (onto which this array member point)
* are NOT owned by this and must be kept alive for the whole lifetime
* of all qpms_scatsys_t objects that are built upon them.
*/
qpms_abstract_tmatrix_t **tmg;
qpms_ss_tmgi_t tmg_count; ///< Number of all different original T-matrix generators in the system.
/// All the different T-matrix functions in the system, including those derived from \a tmg elements by symmetries.
qpms_ss_derived_tmatrix_t *tm;
qpms_ss_tmi_t tm_count; ///< Number of all different T-matrices in the system (length of tm[]).
qpms_ss_tmi_t tm_capacity; ///< Capacity of tm[]. qpms_ss_tmi_t tm_capacity; ///< Capacity of tm[].
qpms_particle_tid_t *p; ///< Particles. qpms_particle_tid_t *p; ///< Particles.
qpms_ss_pi_t p_count; ///< Size of particles array. qpms_ss_pi_t p_count; ///< Size of particles array.
qpms_ss_pi_t p_capacity; ///< Capacity of p[]. qpms_ss_pi_t p_capacity; ///< Capacity of p[].
@ -173,7 +191,7 @@ typedef struct qpms_scatsys_at_omega_t {
const qpms_scatsys_t *ss; ///< Parent scattering system. const qpms_scatsys_t *ss; ///< Parent scattering system.
/// T-matrices from \a ss, evaluated at \a omega. /// T-matrices from \a ss, evaluated at \a omega.
/** The T-matrices are in the same order as in \a ss, /** The T-matrices are in the same order as in \a ss,
* i.e in the order corresponding to TODO WHAT E7ACTLY?? * i.e in the order corresponding to \a ss->tm.
*/ */
qpms_tmatrix_t **tm; qpms_tmatrix_t **tm;
complex double omega; ///< Angular frequency complex double omega; ///< Angular frequency
@ -190,18 +208,32 @@ static inline const qpms_vswf_set_spec_t *qpms_ss_bspec_pi(const qpms_scatsys_t
return ss->tm[ss->p[pi].tmatrix_id]->spec; return ss->tm[ss->p[pi].tmatrix_id]->spec;
} }
/// Creates a new scatsys by applying a symmetry group, copying particles if needed. #if 0 //TODO!!!
/** In fact, it copies everything except the vswf set specs, so keep them alive until scatsys is destroyed. /// Creates a new scatsys by applying a symmetry group onto a "proto-scatsys", copying particles if needed.
* The following fields must be filled: /** In fact, it copies everything except the vswf set specs and qpms_abstract_tmatrix_t instances,
* orig->tm * so keep them alive until scatsys is destroyed.
* orig->tm_count *
* orig->p * The following fields must be filled in the "proto- scattering system" \a orig:
* orig->p_count *
* * orig->tmg The pointers are copied to the new qpms_scatsys_t instance;
* the target qpms_abstract_tmatrix_t objects must be kept alive before all the resulting
* qpms_scatsys_t instances are properly destroyed. The pointers from orig->tmg, however, are copied.
* * orig->tmg_count
* * orig->tm Must be filled, although the operations will typically be identities
* (QPMS_TMATRIX_OPERATION_NOOP). N.B. these NOOPs might be replaced with some symmetrisation operation
* in the resulting "full" qpms_scatsys_t instance.
* * orig->tm_count
* * orig->p
* * orig->p_count
*/ */
qpms_scatsys_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, const struct qpms_finite_group_t *sym); qpms_scatsys_at_omega_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, const struct qpms_finite_group_t *sym);
#endif
/// Destroys the result of qpms_scatsys_apply_symmetry or qpms_scatsys_load. /// Destroys the result of qpms_scatsys_apply_symmetry or qpms_scatsys_load.
void qpms_scatsys_free(qpms_scatsys_t *s); void qpms_scatsys_free(qpms_scatsys_t *s);
/// Destroys the result of qpms_scatsys_eval_at_omega()
void qpms_scatsys_at_omega_free(qpms_scatsys_at_omega *so);
/// Creates a "full" transformation matrix U that takes a full vector and projects it onto an symmetry adapted basis. /// Creates a "full" transformation matrix U that takes a full vector and projects it onto an symmetry adapted basis.
/** Mostly as a reference and a debugging tool, as multiplicating these big matrices would be inefficient. /** Mostly as a reference and a debugging tool, as multiplicating these big matrices would be inefficient.
* *

View File

@ -993,6 +993,8 @@ qpms_errno_t qpms_tmatrix_generator_constant(qpms_tmatrix_t *t,
void qpms_tmatrix_operation_clear(qpms_tmatrix_operation_t *f) { void qpms_tmatrix_operation_clear(qpms_tmatrix_operation_t *f) {
switch(f->typ) { switch(f->typ) {
case QPMS_TMATRIX_OPERATION_NOOP:
break;
case QPMS_TMATRIX_OPERATION_LRMATRIX: case QPMS_TMATRIX_OPERATION_LRMATRIX:
if(f->op.lrmatrix.owns_m) if(f->op.lrmatrix.owns_m)
free(f->op.lrmatrix.m); free(f->op.lrmatrix.m);
@ -1080,6 +1082,8 @@ static qpms_tmatrix_t *qtao_scmulz_inplace(qpms_tmatrix_t *T,
qpms_tmatrix_t *qpms_tmatrix_apply_operation_inplace( qpms_tmatrix_t *qpms_tmatrix_apply_operation_inplace(
const qpms_tmatrix_operation_t *f, qpms_tmatrix_t *T) { const qpms_tmatrix_operation_t *f, qpms_tmatrix_t *T) {
switch(f->typ) { switch(f->typ) {
case QPMS_TMATRIX_OPERATION_NOOP:
return f;
case QPMS_TMATRIX_OPERATION_LRMATRIX: case QPMS_TMATRIX_OPERATION_LRMATRIX:
return qpms_tmatrix_apply_symop_inplace(T, f->op.lrmatrix.m); return qpms_tmatrix_apply_symop_inplace(T, f->op.lrmatrix.m);
case QPMS_TMATRIX_OPERATION_IROT3: case QPMS_TMATRIX_OPERATION_IROT3:

View File

@ -520,6 +520,7 @@ typedef struct qpms_tmatrix_function_t {
/// Specifies different kinds of operations done on T-matrices /// Specifies different kinds of operations done on T-matrices
typedef enum { typedef enum {
QPMS_TMATRIX_OPERATION_NOOP, ///< Identity operation.
QPMS_TMATRIX_OPERATION_LRMATRIX, ///< General matrix transformation \f$ T' = MTM^\dagger \f$; see @ref qpms_tmatrix_operation_lrmatrix. QPMS_TMATRIX_OPERATION_LRMATRIX, ///< General matrix transformation \f$ T' = MTM^\dagger \f$; see @ref qpms_tmatrix_operation_lrmatrix.
QPMS_TMATRIX_OPERATION_IROT3, ///< Single rotoreflection specified by a qpms_irot3_t. QPMS_TMATRIX_OPERATION_IROT3, ///< Single rotoreflection specified by a qpms_irot3_t.
QPMS_TMATRIX_OPERATION_IROT3ARR, ///< Symmetrise using an array of rotoreflection; see @ref qpms_tmatrix_operation_irot3arr. QPMS_TMATRIX_OPERATION_IROT3ARR, ///< Symmetrise using an array of rotoreflection; see @ref qpms_tmatrix_operation_irot3arr.
@ -610,12 +611,6 @@ qpms_tmatrix_t *qpms_tmatrix_apply_operation_inplace(const qpms_tmatrix_operatio
*/ */
void qpms_tmatrix_operation_clear(qpms_tmatrix_operation_t *f); void qpms_tmatrix_operation_clear(qpms_tmatrix_operation_t *f);
/// A recepy to create another T-matrices from qpms_tmatrix_fuction_t by symmetry (or other) operations.
typedef struct qpms_derived_tmatrix_function_t {
const qpms_tmatrix_function_t *t;
const qpms_tmatrix_operation_t *op;
} qpms_derived_tmatrix_function_t;
#if 0 #if 0
// Abstract types that describe T-matrix/particle/scatsystem symmetries // Abstract types that describe T-matrix/particle/scatsystem symmetries