From 3437c2dfe925a5b8f28b5f29ccd980a01d30861d Mon Sep 17 00:00:00 2001 From: Laura Messio Date: Fri, 10 Jan 2014 18:21:08 +0100 Subject: [PATCH] doc: small tutorial for the GF's --- doc/tutorials/c++/contents.rst | 1 + doc/tutorials/c++/gfs_tutorial.rst | 129 +++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 doc/tutorials/c++/gfs_tutorial.rst diff --git a/doc/tutorials/c++/contents.rst b/doc/tutorials/c++/contents.rst index 62823cd9..73d71fa5 100644 --- a/doc/tutorials/c++/contents.rst +++ b/doc/tutorials/c++/contents.rst @@ -10,5 +10,6 @@ C++ libraries array_tutorial det_manip_tutorial + gfs_tutorial .. diff --git a/doc/tutorials/c++/gfs_tutorial.rst b/doc/tutorials/c++/gfs_tutorial.rst new file mode 100644 index 00000000..75ad703b --- /dev/null +++ b/doc/tutorials/c++/gfs_tutorial.rst @@ -0,0 +1,129 @@ +Green function cookbook +======================= + +.. highlight:: c + +.. toctree:: + :maxdepth: 1 + +The gfs class of TRIQS contains objects representing Green functions over real or imaginary times, rela or imaginary frequencies... that can be easily manipulated. +(see :doc:`here <../../reference/c++/gf/contents>`). +Here are a couple of simple examples showing the basic use of this class. + +Creation of a real time GF +----------------------------- + +Here we create a GF define on the time interval from tmin to tmax. +If we want the value of the GF at any time to be a scalar, we use: + +.. compileblock:: + + #include + using namespace triqs::gfs; + + int main() { + double tmin=0, tmax=10; // the time interval + int n_times=100; // we will have 100 points + auto g = gf{ {tmin, tmax, n_times}}; + } + +If we need a matrix of size n by m, we use: + +.. compileblock:: + + #include + using namespace triqs::gfs; + + int main() { + double tmin = 0, tmax = 10; // the time interval + const int n=2, m=2, n_times = 100; // we will have 100 points + auto g = gf{ {tmin, tmax, n_times} , {n, m} }; + } + +Or a tensor ! + +.. compileblock:: + + #include + using namespace triqs::gfs; + + int main() { + double tmin = 0, tmax = 10; // the time interval + double beta=1; + int n_times = 100; // we will have 100 pointspoints + auto g =gf, tensor_valued<3>>{ + { {tmin, tmax, n_times}, {beta, Fermion, n_times} }, {2,2,2}}; + } + + +Creation of other simple GF's +------------------------------- + +.. compileblock:: + + #include + using namespace triqs::gfs; + + int main() { + double beta=10; // the time interval + int n_times=100; // we will have 100 + auto g = gf{ {beta, Fermion, n_times}}; + } + +Creation of a two real time GF +-------------------------------- + +.. compileblock:: + + #include + using namespace triqs::gfs; + int main(){ + double tmin = 0, tmax = 1.0; + int nt = 100; + auto g = gf< cartesian_product,scalar_valued>{{{tmin,tmax,nt},{tmin,tmax,nt}}}; + } + + +How to fill a GF with placeholders +----------------------------------- + +.. compileblock:: + + #include + using namespace triqs::gfs; + int main(){ + double tmin = 0, tmax = 1.0; + int nt = 100; + auto g = gf< cartesian_product,scalar_valued>{{{tmin,tmax,nt},{tmin,tmax,nt}}}; + triqs::clef::placeholder<0> t1_; + triqs::clef::placeholder<1> t2_; + g( t1_, t2_) << 2*t1_; + } + + +How to interpolate the GF value at a point of the domain +--------------------------------------------------------- + +You simply have to call the GF with the coordinates of the point: + +.. compileblock:: + + #include + using namespace triqs::gfs; + int main(){ + double tmin = 0, tmax = 1.0; + int nt = 100; + auto g = gf< cartesian_product, scalar_valued >{ + { {tmin, tmax, nt}, {tmin, tmax, nt} } }; + triqs::clef::placeholder<0> t1_; + triqs::clef::placeholder<1> t2_; + g( t1_, t2_) << 2.*t1_; + std::cout << g(0.24, 0.36) << std::endl; + } + + + + +Learn more in the full reference, see :ref:`gf` + +