23 #include <pybind11/pybind11.h>
24 #include <pybind11/stl.h>
25 #include <pybind11/numpy.h>
28 void add_symmetryNamespace ( pybind11::module& pyProSHADE )
56 pyProSHADE.def (
"optimiseDGroupAngleFromAxesHeights",
60 pybind11::buffer_info selection_buf = selection.request();
61 if ( selection_buf.ndim != 1 ) { std::cerr <<
"!!! ProSHADE PYTHON MODULE ERROR !!! The first argument to optimiseDGroupAngleFromAxesHeights() must be a 1D numpy array!" << std::endl; exit ( EXIT_FAILURE ); }
62 if ( selection_buf.shape.at(0) != 2 ) { std::cerr <<
"!!! ProSHADE PYTHON MODULE ERROR !!! The first argument to optimiseDGroupAngleFromAxesHeights() must be array of length 2!" << std::endl; exit ( EXIT_FAILURE ); }
65 proshade_unsign* arrStart =
static_cast< proshade_unsign*
> ( selection_buf.ptr );
66 std::vector< proshade_unsign > sel;
71 std::vector< std::vector< proshade_double > > allCs;
72 std::vector< proshade_double > hlpVec;
73 for (
size_t it1 = 0; it1 < dataObj->
getCyclicAxes()->size(); it1++ )
85 },
"This function takes two axes with almost dihedral angle and optimises their relative positions as well as orientation with respect to the optimal angle and the rotation function.", pybind11::arg (
"selection" ), pybind11::arg (
"dataObj" ), pybind11::arg (
"settings" ) );
87 pyProSHADE.def (
"findPointFromTranslations",
91 pybind11::buffer_info allCs_buf = allCs.request();
92 if ( allCs_buf.ndim != 2 ) { std::cerr <<
"!!! ProSHADE PYTHON MODULE ERROR !!! The third argument to findPointFromTranslations() must be a 2D numpy array!" << std::endl; exit ( EXIT_FAILURE ); }
95 std::vector< std::vector < proshade_double > > allCAxes;
96 std::vector < proshade_double > hlpVec;
97 float* arrStart =
static_cast< float*
> ( allCs_buf.ptr );
98 for ( proshade_unsign axIt = 0; axIt < static_cast< proshade_unsign > ( allCs_buf.shape.at(0) ); axIt++ )
104 for ( proshade_unsign vIt = 0; vIt < 7; vIt++ )
113 fftw_complex *origMap =
nullptr, *origCoeffs =
nullptr, *rotMapComplex =
nullptr, *rotCoeffs =
nullptr, *trFunc =
nullptr, *trFuncCoeffs =
nullptr;
114 fftw_plan planForwardFourier, planForwardFourierRot, planReverseFourierComb;
115 ProSHADE_internal_symmetry::allocateCentreOfMapFourierTransforms ( dataObj->
getXDim(), dataObj->
getYDim(), dataObj->
getZDim(), origMap, origCoeffs, rotMapComplex, rotCoeffs, trFunc, trFuncCoeffs, &planForwardFourier, &planForwardFourierRot, &planReverseFourierComb );
118 for (
size_t it = 0; it < static_cast< size_t > ( dataObj->
getXDim() * dataObj->
getYDim() * dataObj->
getZDim() ); it++ ) { origMap[it][0] = dataObj->
getMapValue( it ); origMap[it][1] = 0.0; }
119 fftw_execute ( planForwardFourier );
122 std::vector< proshade_unsign > axLst;
123 std::vector< std::vector< proshade_double > > symElems;
128 origCoeffs, rotMapComplex,
129 rotCoeffs, planForwardFourierRot,
130 trFuncCoeffs, trFunc,
131 planReverseFourierComb );
137 proshade_double* npVals =
new proshade_double[3];
141 for ( proshade_unsign iter = 0; iter < 3; iter++ ) { npVals[iter] =
static_cast< proshade_double
> ( pointPos.at(iter) ); }
144 pybind11::capsule pyCapsuleSymPoint ( npVals, [](
void *f ) { proshade_double* foo =
reinterpret_cast< proshade_double*
> ( f );
delete foo; } );
147 pybind11::array_t < proshade_double > retArr = pybind11::array_t< proshade_double > ( {
static_cast<int> ( 3 ) },
148 {
sizeof(proshade_double) },
156 },
"This function computes the average of optimal translations for a cyclic point group.", pybind11::arg (
"settings" ), pybind11::arg (
"dataObj" ), pybind11::arg (
"allCs" ), pybind11::arg (
"whichAxis" ) );