TBTK
Need a break? Support the development by playing Polarity Puzzles
FileReader.h
Go to the documentation of this file.
1 /* Copyright 2016 Kristofer Björnson and Andreas Theiler
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
24 #ifndef COM_DAFER45_TBTK_FILE_READER
25 #define COM_DAFER45_TBTK_FILE_READER
26 
28 #include "TBTK/Geometry.h"
29 #include "TBTK/Model.h"
30 #include "TBTK/ParameterSet.h"
32 #include "TBTK/Property/DOS.h"
33 #include "TBTK/Property/Density.h"
35 #include "TBTK/Property/LDOS.h"
36 #include "TBTK/Property/SpectralFunction.h"
39 
40 #include <fstream>
41 #include <stdio.h>
42 
43 namespace TBTK{
44 
50 class FileReader{
51 public:
53  static Model* readModel(
54  std::string name = "Model",
55  std::string path = "/"
56  );
57 
60  std::string name = "HoppingAmplitudeSet",
61  std::string path = "/"
62  );
63 
65  static Geometry* readGeometry(
66  Model *model,
67  std::string name = "Geometry",
68  std::string path = "/"
69  );
70 
72  static IndexTree* readIndexTree(
73  std::string name = "IndexTree",
74  std::string path = "/"
75  );
76 
79  std::string name = "EigenValues",
80  std::string path = "/"
81  );
82 
85  std::string name = "WaveFunctions",
86  std::string pat = "/"
87  );
88 
90  static Property::DOS* readDOS(
91  std::string name = "DOS",
92  std::string path = "/"
93  );
94 
97  std::string name = "Density",
98  std::string path = "/"
99  );
100 
103  std::string name = "Magnetization",
104  std::string path = "/"
105  );
106 
108  static Property::LDOS* readLDOS(
109  std::string name = "LDOS",
110  std::string path = "/"
111  );
112 
114  static Property::SpectralFunction* readSpectralFunction(
115  std::string name = "SpectralFunction",
116  std::string path = "/"
117  );
118 
121  std::string name = "SpinPolarizedLDOS",
122  std::string path = "/"
123  );
124 
127  std::string name = "ParameterSet",
128  std::string path = "/"
129  );
130 
132  static void read(
133  int **data,
134  int *rank,
135  int **dims,
136  std::string name,
137  std::string path = "/"
138  );
139 
141  static void read(
142  double **data,
143  int *rank,
144  int **dims,
145  std::string name,
146  std::string path = "/"
147  );
148 
151  static void read(
152  std::complex<double> **data,
153  int *rank,
154  int **dims,
155  std::string name,
156  std::string path = "/"
157  );
158 
160  static void readAttributes(
161  int *attributes,
162  std::string *attribute_names,
163  int num,
164  std::string name,
165  std::string path = "/"
166  );
167 
169  static void readAttributes(
170  double *attributes,
171  std::string *attribute_names,
172  int num,
173  std::string name,
174  std::string path = "/"
175  );
176 
178  static void setFileName(std::string filename);
179 
182  static void clear();
183 
185  static bool exists();
186 private:
188  static bool isInitialized;
189 
191  static std::string filename;
192 };
193 
194 inline Property::SpectralFunction* FileReader::readSpectralFunction(
195  std::string name,
196  std::string path
197 ){
198  return reinterpret_cast<Property::SpectralFunction*>(readLDOS(name, path));
199 }
200 
201 inline void FileReader::setFileName(std::string filename){
202  FileReader::filename = filename;
203  isInitialized = false;
204 }
205 
206 inline void FileReader::clear(){
207  remove(filename.c_str());
208  isInitialized = false;
209 }
210 
211 }; //End of namespace TBTK
212 
213 #endif
214 
TBTK::FileReader::readIndexTree
static IndexTree * readIndexTree(std::string name="IndexTree", std::string path="/")
TBTK::FileReader::readDensity
static Property::Density * readDensity(std::string name="Density", std::string path="/")
TBTK::Model
Container of Model related information.
Definition: Model.h:57
TBTK::Property::DOS
Property container for density of states (DOS).
Definition: DOS.h:48
Model.h
Container of Model related information.
EigenValues.h
Property container for eigen values.
TBTK::ParameterSet
Definition: ParameterSet.h:34
TBTK::Property::SpinPolarizedLDOS
Property container for spin-polarized local density of states (spin-polarized LDOS).
Definition: SpinPolarizedLDOS.h:46
TBTK::FileReader::clear
static void clear()
Definition: FileReader.h:206
Geometry.h
Contains geometric inforamtion about a Model.
TBTK::FileReader::readSpectralFunction
static Property::SpectralFunction * readSpectralFunction(std::string name="SpectralFunction", std::string path="/")
Definition: FileReader.h:194
TBTK::FileReader::readDOS
static Property::DOS * readDOS(std::string name="DOS", std::string path="/")
HoppingAmplitudeSet.h
HoppingAmplitude container.
TBTK::Property::LDOS
Property container for the local density of states (LDOS).
Definition: LDOS.h:48
WaveFunctions.h
Property container for wave functions.
TBTK::HoppingAmplitudeSet
HoppingAmplitude container.
Definition: HoppingAmplitudeSet.h:50
TBTK::FileReader
Definition: FileReader.h:50
TBTK::FileReader::exists
static bool exists()
TBTK::FileReader::readEigenValues
static Property::EigenValues * readEigenValues(std::string name="EigenValues", std::string path="/")
TBTK::FileReader::readLDOS
static Property::LDOS * readLDOS(std::string name="LDOS", std::string path="/")
TBTK::FileReader::setFileName
static void setFileName(std::string filename)
Definition: FileReader.h:201
LDOS.h
Property container for local density of states (LDOS).
TBTK::Geometry
Contains geometric information about a Model.
Definition: Geometry.h:34
SpinPolarizedLDOS.h
Property container for spin-polarized local density of states (spin-polarized LDOS).
DOS.h
Property container for density of states (DOS).
TBTK::Property::Density
Property container for density.
Definition: Density.h:43
TBTK::FileReader::readModel
static Model * readModel(std::string name="Model", std::string path="/")
Magnetization.h
Property container for magnetization.
TBTK::FileReader::readMagnetization
static Property::Magnetization * readMagnetization(std::string name="Magnetization", std::string path="/")
TBTK::IndexTree
Data structure for mapping physical indices to linear indices.
Definition: IndexTree.h:35
Density.h
Property container for density.
TBTK::FileReader::readHoppingAmplitudeSet
static HoppingAmplitudeSet * readHoppingAmplitudeSet(std::string name="HoppingAmplitudeSet", std::string path="/")
TBTK::FileReader::readAttributes
static void readAttributes(int *attributes, std::string *attribute_names, int num, std::string name, std::string path="/")
TBTK::FileReader::readWaveFunctions
static Property::WaveFunctions * readWaveFunctions(std::string name="WaveFunctions", std::string pat="/")
TBTK::FileReader::readSpinPolarizedLDOS
static Property::SpinPolarizedLDOS * readSpinPolarizedLDOS(std::string name="SpinPolarizedLDOS", std::string path="/")
TBTK::FileReader::readParameterSet
static ParameterSet * readParameterSet(std::string name="ParameterSet", std::string path="/")
TBTK::FileReader::readGeometry
static Geometry * readGeometry(Model *model, std::string name="Geometry", std::string path="/")
ParameterSet.h
Set of parameters.
TBTK::FileReader::read
static void read(int **data, int *rank, int **dims, std::string name, std::string path="/")
TBTK::Property::EigenValues
Property container for eigen values.
Definition: EigenValues.h:46
TBTK::Property::WaveFunctions
Property container for wave function.
Definition: WaveFunctions.h:45
TBTK::Property::Magnetization
Property container for magnetization.
Definition: Magnetization.h:44