Commit ce0c2f7a authored by Tobias WEBER's avatar Tobias WEBER

continued with lecture notes

parent 18dfad12
......@@ -63,3 +63,4 @@ stack.hh
*.log
*.aux
*.pdf
*.synctex.*
This diff is collapsed.
......@@ -18,7 +18,7 @@
\begin{document}
Useful formulas, T. Weber, tweber@ill.fr, July 13, 2018.
Useful formulas and derivations, T. Weber, tweber@ill.fr, July 13, 2018.
......@@ -28,6 +28,10 @@ Useful formulas, T. Weber, tweber@ill.fr, July 13, 2018.
\section{Fractional Coordinates}
\begin{center}
\includegraphics[width = 0.2 \textwidth]{cell}
\end{center}
\subsection*{Basic Properties}
From the cosine theorem we get:
......@@ -103,11 +107,19 @@ where $-t$ denotes the transposed inverse.
% ------------------------------------------------------------------------------------------------------------------------------------
\section{Scattering Triangle}
\section{TAS Angles and Scattering Triangle}
\begin{center}
\includegraphics[width = 0.2 \textwidth]{triangle}
\end{center}
\subsection*{Monochromator Angles $a_1$, $a_2$ and Analyser Angles $a_5$, $a_6$}
The monochromator (and analyser) angles follow directly from Bragg's equation:
\begin{equation} 2 k_{i,f} \sin a_{1,5} = 2 \pi / d_{m,a}, \end{equation}
\begin{equation} \boxed{ a_{1,5} = \arcsin \left( \frac{\pi}{d_{m,a} \cdot k_{i,f}} \right). } \end{equation}
Fulfilling the Bragg condition, the angles $a_2$ and $a_6$ are simply: $a_{2,6} = 2 \cdot a_{1,5}.$
\subsection*{Scattering Angle $a_4$}
......
......@@ -587,7 +587,7 @@ requires is_basic_vec<t_vec>
template<class t_mat,
template<class...> class t_cont_outer = std::initializer_list,
template<class...> class t_cont = std::initializer_list>
t_mat create(const t_cont_outer<t_cont<typename t_mat::value_type>>& lst)
t_mat create_mat(const t_cont_outer<t_cont<typename t_mat::value_type>>& lst)
requires is_mat<t_mat>
{
const std::size_t iCols = lst.size();
......@@ -612,6 +612,19 @@ requires is_mat<t_mat>
}
/**
* create matrix from nested initializer_lists in columns/rows order
*/
template<class t_mat,
template<class...> class t_cont_outer = std::initializer_list,
template<class...> class t_cont = std::initializer_list>
t_mat create(const t_cont_outer<t_cont<typename t_mat::value_type>>& lst)
requires is_mat<t_mat>
{
return create_mat<t_mat, t_cont_outer, t_cont>(lst);
}
/**
* create matrix from column (or row) vectors
*/
......@@ -641,7 +654,7 @@ requires is_mat<t_mat> && is_basic_vec<t_vec>
* create matrix from initializer_list in column/row order
*/
template<class t_mat>
t_mat create(const std::initializer_list<typename t_mat::value_type>& lst)
t_mat create_mat(const std::initializer_list<typename t_mat::value_type>& lst)
requires is_mat<t_mat>
{
const std::size_t N = std::sqrt(lst.size());
......@@ -662,6 +675,17 @@ requires is_mat<t_mat>
}
/**
* create matrix from initializer_list in column/row order
*/
template<class t_mat>
t_mat create(const std::initializer_list<typename t_mat::value_type>& lst)
requires is_mat<t_mat>
{
return create_mat<t_mat>(lst);
}
/**
* convert between vector types
*/
......@@ -3570,7 +3594,28 @@ requires is_mat<t_mat> && is_complex<typename t_mat::value_type>
/**
* crystallographic B matrix, B = 2pi * A^(-T)
* real crystallographic A matrix
* after: https://en.wikipedia.org/wiki/Fractional_coordinates
*/
template<class t_mat, class t_real = typename t_mat::value_type>
t_mat A_matrix(t_real a, t_real b, t_real c, t_real _aa, t_real _bb, t_real _cc)
requires is_mat<t_mat>
{
const t_real ca = std::cos(_aa);
const t_real cb = std::cos(_bb);
const t_real cc = std::cos(_cc);
const t_real sc = std::sin(_cc);
return create<t_mat>({
a, b*cc, c*cb,
t_real{0}, b*sc, c*(ca -cc*cb)/sc,
t_real{0}, t_real{0}, c*std::sqrt(t_real{1} - cb*cb - std::pow((ca - cc*cb)/sc, t_real{2}))
});
}
/**
* reciprocal crystallographic B matrix, B = 2pi * A^(-T)
* after: https://en.wikipedia.org/wiki/Fractional_coordinates
*/
template<class t_mat, class t_real = typename t_mat::value_type>
......@@ -3583,9 +3628,9 @@ requires is_mat<t_mat>
const t_real cc = std::cos(_cc);
const t_real rr = std::sqrt(1. + 2.*ca*cb*cc - (ca*ca + cb*cb + cc*cc));
return t_real(2)*pi<t_real> * create<t_mat>({
1./a, 0., 0.,
-1./a * cc/sc, 1./b * 1./sc, 0.,
return t_real{2}*pi<t_real> * create<t_mat>({
t_real{1}/a, t_real{0}, t_real{0},
-t_real{1}/a * cc/sc, t_real{1}/b * t_real{1}/sc, t_real{0},
(cc*ca - cb)/(a*sc*rr), (cb*cc-ca)/(b*sc*rr), sc/(c*rr)
});
}
......
/**
* crystal matrix text
* @author Tobias Weber <tweber@ill.fr>
* @date feb-19
* @license GPLv3, see 'LICENSE' file
*
* g++-8 -std=c++17 -fconcepts -DUSE_LAPACK -I/usr/include/lapacke -I/usr/local/opt/lapack/include -L/usr/local/opt/lapack/lib -o cryst cryst.cpp -llapacke
*/
#include <iostream>
#include <vector>
#include "../../libs/_cxx20/math_algos.h"
using namespace m_ops;
using t_real = double;
//using t_real = float;
using t_cplx = std::complex<t_real>;
using t_vec = std::vector<t_real>;
using t_mat = m::mat<t_real, std::vector>;
using t_vec_cplx = std::vector<t_cplx>;
using t_mat_cplx = m::mat<t_cplx, std::vector>;
int main()
{
auto A = m::A_matrix<t_mat>(3., 4., 5., 80./180.*M_PI, 100./180.*M_PI, 60./180.*M_PI);
auto B = m::B_matrix<t_mat>(3., 4., 5., 80./180.*M_PI, 100./180.*M_PI, 60./180.*M_PI);
auto [B2, ok] = m::inv(A);
B2 = 2.*M_PI * m::trans(B2);
std::cout << "A = " << A << std::endl;
std::cout << "B = " << B << std::endl;
std::cout << "B2 = " << B2 << std::endl;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment