Commit ce0c2f7a authored by Tobias WEBER's avatar Tobias WEBER
Browse files

continued with lecture notes

parent 18dfad12
......@@ -63,3 +63,4 @@ stack.hh
*.log
*.aux
*.pdf
*.synctex.*
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="721.80981mm"
height="815.75104mm"
viewBox="0 0 721.80982 815.75104"
version="1.1"
id="svg8"
sodipodi:docname="cell.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2">
<marker
inkscape:stockid="Arrow2Mend"
orient="auto"
refY="0"
refX="0"
id="marker1477"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path1475"
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="marker1327"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Mend"
inkscape:collect="always">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#00ff00;fill-opacity:1;fill-rule:evenodd;stroke:#00ff00;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path1325"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="Arrow2Mend"
orient="auto"
refY="0"
refX="0"
id="Arrow2Mend"
style="overflow:visible"
inkscape:isstock="true"
inkscape:collect="always">
<path
id="path1006"
style="fill:#fd0000;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)"
inkscape:connector-curvature="0" />
</marker>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="91.756739 : 520.37834 : 0"
inkscape:vp_y="766.04444 : 642.7876 : 0"
inkscape:vp_z="402.9948 : -252.79817 : 0"
inkscape:persp3d-origin="-13.309906 : 509.53176 : 1"
id="perspective815" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.22627417"
inkscape:cx="1597.849"
inkscape:cy="1552.2027"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1616"
inkscape:window-height="1122"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:creator>
<cc:Agent>
<dc:title>tweber</dc:title>
</cc:Agent>
</dc:creator>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-118.30991,108.21926)">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="452.84079"
y="345.07593"
id="text1824"><tspan
sodipodi:role="line"
id="tspan1822"
x="452.84079"
y="345.07593"
style="font-size:88.19444275px;fill:#0000ff;fill-opacity:1;stroke-width:0.26458332">γ</tspan></text>
<g
sodipodi:type="inkscape:box3d"
id="g847"
style="opacity:1;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:none"
inkscape:perspectiveID="#perspective815"
inkscape:corner0="-0.12295849 : 0.55734914 : 0 : 1"
inkscape:corner7="-0.73884464 : 0.11836195 : 0.78772176 : 1">
<path
sodipodi:type="inkscape:box3dside"
id="path851"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:box3dsidetype="5"
d="m 520.67194,-96.272161 -56.5117,320.493811 317.44777,199.13463 56.5117,-320.49382 z"
points="464.16024,224.22165 781.60801,423.35628 838.11971,102.86246 520.67194,-96.272161 " />
<path
sodipodi:type="inkscape:box3dside"
id="path849"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:box3dsidetype="6"
d="M 520.67194,-96.272161 184.38825,185.90336 501.83602,385.03798 838.11971,102.86246 Z"
points="184.38825,185.90336 501.83602,385.03798 838.11971,102.86246 520.67194,-96.272161 " />
<path
sodipodi:type="inkscape:box3dside"
id="path859"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:box3dsidetype="11"
d="M 838.11971,102.86246 781.60801,423.35628 445.32431,705.5318 501.83602,385.03798 Z"
points="781.60801,423.35628 445.32431,705.5318 501.83602,385.03798 838.11971,102.86246 " />
<path
sodipodi:type="inkscape:box3dside"
id="path857"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:box3dsidetype="13"
d="M 184.38825,185.90336 127.87654,506.39718 445.32431,705.5318 501.83602,385.03798 Z"
points="127.87654,506.39718 445.32431,705.5318 501.83602,385.03798 184.38825,185.90336 " />
<path
sodipodi:type="inkscape:box3dside"
id="path855"
style="fill:none;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:box3dsidetype="14"
d="M 464.16024,224.22165 127.87654,506.39718 445.32431,705.5318 781.60801,423.35628 Z"
points="127.87654,506.39718 445.32431,705.5318 781.60801,423.35628 464.16024,224.22165 " />
<path
sodipodi:type="inkscape:box3dside"
id="path853"
style="fill:none;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:box3dsidetype="3"
d="M 520.67194,-96.272161 464.16024,224.22165 127.87654,506.39718 184.38825,185.90336 Z"
points="464.16024,224.22165 127.87654,506.39718 184.38825,185.90336 520.67194,-96.272161 " />
</g>
<path
style="fill:#fd0000;fill-opacity:1;stroke:#ff0000;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
d="M 464.16024,224.22166 127.87655,506.39718"
id="path977"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:#00ff00;fill-opacity:1;stroke:#00ff00;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker1327)"
d="M 464.16024,224.22166 781.60801,423.35628"
id="path1317"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:#0000ff;fill-opacity:1;stroke:#0000ff;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker1477)"
d="m 464.16024,224.22166 56.5117,-320.493821"
id="path1467"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:70.55555725px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="191.95467"
y="526.20624"
id="text1773"><tspan
sodipodi:role="line"
id="tspan1771"
x="191.95467"
y="526.20624"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:88.19444275px;line-height:0;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;fill-opacity:1;stroke-width:0.26458332">a</tspan><tspan
sodipodi:role="line"
x="191.95467"
y="614.4007"
style="font-size:70.55555725px;line-height:0;stroke-width:0.26458332"
id="tspan1775" /></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:#00ff00;stroke-width:0.26458332;stroke-opacity:1"
x="657.23114"
y="461.84583"
id="text1779"><tspan
sodipodi:role="line"
id="tspan1777"
x="657.23114"
y="461.84583"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:88.19444275px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#00ff00;fill-opacity:1;stroke:#00ff00;stroke-width:0.26458332;stroke-opacity:1">b</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="434.50757"
y="28.126436"
id="text1783"><tspan
sodipodi:role="line"
id="tspan1781"
x="434.50757"
y="28.126436"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:88.19444275px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;fill-opacity:1;stroke-width:0.26458332">c</tspan></text>
<path
style="fill:none;fill-opacity:1;stroke:#00fc00;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 464.42394,172.99425 c -44.95783,21.94135 -57.04799,56.47032 -50.28007,98.22153"
id="path1808"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#ff0000;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 464.42394,172.99425 c 33.36113,12.01871 57.26132,37.40794 48.5743,92.99043"
id="path1810"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#0000fd;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 414.14387,271.21578 c 39.26641,19.30615 72.8116,19.54157 98.85436,-5.2311"
id="path1812"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="520.43964"
y="210.3869"
id="text1816"><tspan
sodipodi:role="line"
id="tspan1814"
x="520.43964"
y="210.3869"
style="font-size:88.19444275px;fill:#ff0000;fill-opacity:1;stroke-width:0.26458332">α</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#00f700;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1"
x="357.49677"
y="209.07576"
id="text1820"><tspan
sodipodi:role="line"
id="tspan1818"
x="357.49677"
y="209.07576"
style="font-size:88.19444275px;fill:#00f700;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1">β</tspan></text>
</g>
</svg>
......@@ -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