Skip to content
Open
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2019-2020, Mrsimulator Developors
Copyright (c) 2019-2021, Mrsimulator Developors
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 2 additions & 2 deletions docs/configuring_simulator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ of the config attributes is as follows,
...
>>> sim = Simulator()
>>> sim.config
ConfigSimulator(number_of_sidebands=64, integration_volume='octant', integration_density=70, decompose_spectrum='none')
ConfigSimulator(number_of_sidebands=64, integration_type='Alderman', integration_volume='octant', integration_density=70, decompose_spectrum='none')

Here, the configurable attributes are ``number_of_sidebands``,
Here, the configurable attributes are ``number_of_sidebands``, ``integration_type``,
``integration_volume``, ``integration_density``, and ``decompose_spectrum``.


Expand Down
2 changes: 1 addition & 1 deletion docs/credits/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Mrsimulator License

Mrsimulator is licensed under BSD 3-Clause License

Copyright (c) 2019-2020, Mrsimulator Developors,
Copyright (c) 2019-2021, Mrsimulator Developors,

All rights reserved.

Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ def message(lib):
source = [
"src/c_lib/lib/angular_momentum.c",
"src/c_lib/lib/interpolation.c",
"src/c_lib/lib/method.c",
"src/c_lib/lib/mrsimulator.c",
"src/c_lib/lib/octahedron.c",
"src/c_lib/lib/simulation.c",
"src/c_lib/lib/powder_setup.c",
"src/c_lib/lib/schemes.c",
"src/c_lib/lib/method.c",
"src/c_lib/lib/simulation.c",
"src/c_lib/lib/spherical.c",
]

ext = ".pyx" if USE_CYTHON else ".c"
Expand Down
8 changes: 5 additions & 3 deletions src/c_lib/base/base_model.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# nmr_method.pxd
#
# @copyright Deepansh J. Srivastava, 2019-2020.
# @copyright Deepansh J. Srivastava, 2019-2021.
# Created by Deepansh J. Srivastava.
# Contact email = srivastava.89@osu.edu
#
Expand All @@ -17,9 +17,10 @@ cdef extern from "schemes.h":
unsigned int total_orientations

MRS_averaging_scheme *MRS_create_averaging_scheme(
unsigned int integration_type,
unsigned int integration_density,
bool_t allow_fourth_rank,
unsigned int integration_volume)
unsigned int integration_volume,
bool_t allow_fourth_rank)

void MRS_free_averaging_scheme(MRS_averaging_scheme *scheme)

Expand Down Expand Up @@ -112,6 +113,7 @@ cdef extern from "simulation.h":

# The transition as transition[0] = mi and transition[1] = mf
float *transition,
unsigned int integration_type, # 0-octahedron, 1-sphere
int integration_density,
unsigned int integration_volume, # 0-octant, 1-hemisphere, 2-sphere
bool_t interpolation,
Expand Down
5 changes: 3 additions & 2 deletions src/c_lib/base/base_model.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def one_d_spectrum(method,
list spin_systems,
int verbose=0,
unsigned int number_of_sidebands=90,
unsigned int integration_type=1,
unsigned int integration_density=72,
unsigned int decompose_spectrum=0,
unsigned int integration_volume=1,
Expand Down Expand Up @@ -84,8 +85,8 @@ def one_d_spectrum(method,
# create averaging scheme _____________________________________________________
cdef clib.MRS_averaging_scheme *the_averaging_scheme
the_averaging_scheme = clib.MRS_create_averaging_scheme(
integration_density=integration_density, allow_fourth_rank=allow_fourth_rank,
integration_volume=integration_volume
integration_type=integration_type, integration_density=integration_density,
integration_volume=integration_volume, allow_fourth_rank=allow_fourth_rank
)

# create spectral dimensions _______________________________________________
Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/angular_momentum.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// angular_momentum.c
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava.
// Contact email = srivastava.89@osu.edu

Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// array.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019
// Contact email = srivastava.89@osu.edu
//
Expand Down
5 changes: 3 additions & 2 deletions src/c_lib/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// config.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Aug 10, 2019
// Contact email = srivastava.89@osu.edu
//
Expand Down Expand Up @@ -52,7 +52,8 @@ typedef float complex64[2];
#include "vm.h"

// user definition
#define PI2 6.2831853072
#define PI2 6.283185307179586
#define PIby2 1.570796326794897
#define PI2I PI2 *I

// #ifdef linux
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// spatial_orientation_tensors.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Aug 26, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// spin_transition_function.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/frequency_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// frequency_component_function.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/interpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// interpolation.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019
// Contact email = srivastava.89@osu.edu
//
Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/isotopomer_ravel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// isotopomer_ravel.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/method.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// method.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 15, 2020.
// Contact email = srivastava.89@osu.edu
//
Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/mrsimulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// mrsimulator.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Jun 30, 2019
// Contact email = srivastava.89@osu.edu
//
Expand Down
19 changes: 11 additions & 8 deletions src/c_lib/include/octahedron.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
//
// powder_setup.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019.
// Contact email = srivastava.89@osu.edu
//

#include "config.h"
#include "interpolation.h"

extern void octahedronGetDirectionCosineSquareOverOctantAndWeights(
int nt, double *xr, double *yr, double *zr, double *amp);
extern void octahedronGetDirectionCosineSquareAndWeightsOverOctant(
int nt, double *restrict xr, double *restrict yr, double *restrict zr,
double *restrict amp);

extern void octahedronGetPolarAngleTrigOverAnOctant(int nt, double *cos_alpha,
double *cos_beta,
double *amp);
extern void octahedronGetPolarAngleTrigOverOctant(int nt, double *cos_alpha,
double *cos_beta,
double *amp);

extern void octahedronGetPolarAngleCosineAzimuthalAnglePhaseOverOctant(
int nt, void *exp_I_alpha, void *exp_I_beta, double *amp);
extern void octahedronGetComplexExpOfPolarAngleOverOctant(int nt,
void *exp_I_alpha,
void *exp_I_beta,
double *amp);

extern void octahedronInterpolation(double *spec, double *freq, int nt,
double *amp, int stride, int m);
Expand Down
6 changes: 3 additions & 3 deletions src/c_lib/include/powder_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
//
// powder_setup.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019.
// Contact email = srivastava.89@osu.edu
//

#include "config.h"

extern void octahedron_averaging_setup(int nt, void *exp_I_alpha,
void *exp_I_beta, double *amp);
extern void averaging_setup(unsigned int integration_type, int nt,
void *exp_I_alpha, void *exp_I_beta, double *amp);
18 changes: 12 additions & 6 deletions src/c_lib/include/schemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// schemes.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Sep 3, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down Expand Up @@ -40,8 +40,11 @@ typedef struct MRS_averaging_scheme {
unsigned int total_orientations; /**< The total number of orientations. */

/** \privatesection */
unsigned int integration_density; // number of triangles along the edge of
// the octahedron.
unsigned int integration_type; // Sampling type for integration
// 0-octaheron, 1-spherical
unsigned int integration_density; // number of triangles along the edge
// of the octahedron.
unsigned int integration_volume; // 0-octant, 1-hemisphere, 2-sphere.
unsigned int octant_orientations; // number of unique orientations on the
// face of an octant.
double *amplitudes; // array of amplitude scaling per orientation.
Expand All @@ -52,7 +55,6 @@ typedef struct MRS_averaging_scheme {
double *wigner_4j_matrices; // wigner-d 4j matrix per orientation.
// double *local_frequency; // buffer for local frequencies.
// double *freq_offset; // buffer for local + sideband frequencies.
unsigned int integration_volume; // 0-octant, 1-hemisphere, 2-sphere.
bool allow_fourth_rank; // If true, compute wigner matrices for wigner-d 4j.
} MRS_averaging_scheme;

Expand All @@ -77,8 +79,8 @@ typedef struct MRS_averaging_scheme {
* @param integration_volume An enumeration. 0=octant, 1=hemisphere
*/
MRS_averaging_scheme *MRS_create_averaging_scheme(
unsigned int integration_density, bool allow_fourth_rank,
unsigned int integration_volume);
unsigned int integration_type, unsigned int integration_density,
unsigned int integration_volume, bool allow_fourth_rank);

/**
* Create a new orientation averaging scheme from given alpha and beta.
Expand All @@ -105,6 +107,10 @@ MRS_averaging_scheme *MRS_create_averaging_scheme_from_alpha_beta(
*/
void MRS_free_averaging_scheme(MRS_averaging_scheme *scheme);

static inline void averaging_scheme_setup(MRS_averaging_scheme *scheme,
complex128 *exp_I_beta,
bool allow_fourth_rank);

#endif // averaging_scheme_h

#ifndef fftw_scheme_h
Expand Down
3 changes: 2 additions & 1 deletion src/c_lib/include/simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// simulation.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Apr 11, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down Expand Up @@ -35,6 +35,7 @@ extern void mrsimulator_core(

// powder orientation average
// The number of triangle along the edge of octahedron.
unsigned int integration_type, // 0-octahedron, 1-sphere
int integration_density,
unsigned int integration_volume, // 0-octant, 1-hemisphere, 2-sphere.
bool interpolation, bool *freq_contrib, double *affine_matrix);
Expand Down
19 changes: 19 additions & 0 deletions src/c_lib/include/spherical.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// -*- coding: utf-8 -*-
//
// spherical.h
//
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Feb 12, 2021.
// Contact email = srivastava.89@osu.edu
//

#include "config.h"
#include "interpolation.h"

extern void sphericalGetCoordinates(int nt, double *restrict x,
double *restrict y, double *restrict z);

extern void sphericalGetComplexExpOfPolarAngleOverOctant(int nt,
void *exp_I_alpha,
void *exp_I_beta,
double *amp);
20 changes: 11 additions & 9 deletions src/c_lib/include/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// vm.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Jul 26, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down Expand Up @@ -243,15 +243,16 @@ static inline void vm_double_complex_multiply(int count, const void *restrict x,
* res = cos(x)
*/
static inline void vm_double_cosine(int count, const double *restrict x,
double *restrict res) {
int stride_x, double *restrict res,
int stride_res) {
// x = __builtin_assume_aligned(x, 32);
// res = __builtin_assume_aligned(res, 32);
while (count-- > 0) {
*res++ = cos(*x++);
*res = cos(*x);
// res++;
// x++;
// x += stride_x;
// res += stride_res;
x += stride_x;
res += stride_res;
}
}

Expand All @@ -260,13 +261,14 @@ static inline void vm_double_cosine(int count, const double *restrict x,
* res = sin(x)
*/
static inline void vm_double_sine(int count, const double *restrict x,
double *restrict res) {
int stride_x, double *restrict res,
int stride_res) {
// x = __builtin_assume_aligned(x, 32);
// res = __builtin_assume_aligned(res, 32);
while (count-- > 0) {
*res++ = sin(*x++);
// x += stride_x;
// res += stride_res;
*res = sin(*x);
x += stride_x;
res += stride_res;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/c_lib/include/vm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// vm_common.h
//
// @copyright Deepansh J. Srivastava, 2019-2020.
// @copyright Deepansh J. Srivastava, 2019-2021.
// Created by Deepansh J. Srivastava, Jul 26, 2019.
// Contact email = srivastava.89@osu.edu
//
Expand Down
Loading