Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
Read_Siesta_XML.m
Go to the documentation of this file.
1 %> @file Read_Siesta_XML.m
2 %> @brief Parses the SIESTA XML output and looks for relevant data
3 %> @Available
4 %> EQuUs v4.9 or later
5 %>
6 %> @param 'xmlfile' the xml output of the SIESTA calculation.
7 %> @param 'fields' what entries to read from the file.
8  function xml_params = Read_Siesta_XML(xmlfile, fields, readanyway)
9 
10  %SOME CONSTANTS USED IN SIESTA
11  RytoeV = 1/13.60580; % Rydberg to eV
12  Bohr = 0.529177; % Angstrom
13 
14  %THAT IS THE XML FILE THAT HOPEFULLY COMES OUT OF SIESTA AS DEFAULT
15  if exist(xmlfile, 'file') == 0
16  disp(['ERROR: There is no file: ' xmlfile])
17  throw(['ERROR: There is no file: ' xmlfile])
18  end
19 
20  xml_params = [];
21 
22  tmp = read_SiestaXML( xmlfile, fields );
23 
24  %%convert tmp to make in unfallable
25  if isfield(tmp, 'property')
26  if isstruct(tmp.property)
27  property{1} = tmp.property;
28  else
29  property = tmp.property;
30  end
31  else
32  property = nan;
33  end
34 
35  if isfield(tmp, 'propertyList')
36  if isstruct(tmp.propertyList)
37  propertyList{1} = tmp.propertyList;
38  else
39  propertyList = tmp.propertyList;
40  end
41  else
42  propertyList = nan;
43  end
44 
45  if isfield(tmp, 'module')
46  module{1} = tmp.module;
47  else
48  module = nan;
49  end
50 
51  if iscell(propertyList)
52  for i=1:length(propertyList)
53  if strcmp(propertyList{i}.dictRef,'siesta:kpoints')
54  %READ MONKHORST PACK K POINTS FROM "system_label.xml" ('K')
55  Tkpoints=propertyList{i}.subnodes.kpoint;
56  if length(Tkpoints)==1
57  kp(1,1:4)=[0,0,0,1];
58  else
59  for ik=1:length(Tkpoints)
60  kp(ik,1:4) = [str2num(Tkpoints{ik}.coords) str2num(Tkpoints{ik}.weight)];
61  end
62  end
63  xml_params.kpoints = kp;
64  end
65  end
66  end
67 
68  %% READ FERMI ENERGY FROM FILE
69  if iscell(property)
70  for i=1:length(property)
71  if strcmp(property{i}.dictRef,'siesta:E_Fermi')
72  EF = str2num(property{i}.subnodes.scalar.value);
73  %EF = EF - EF_shift;
74  xml_params.E_Fermi = EF;
75  end
76  end
77  end
78 
79  %% READ K-SUPERCELL SIZE FROM FILE
80  if iscell(property)
81  for i=1:length(property)
82  if strcmp(property{i}.dictRef,'siesta:kscell')
83  xml_params.kscell = reshape(str2num(property{i}.subnodes.matrix.value), [3,3]);
84  end
85  end
86  end
87 
88  %COORDS and %LATTICE VECTORS
89  if iscell(module)
90  subnodes = module{1}.subnodes;
91  coords=[];
92  Tatom=subnodes.molecule.subnodes.atomArray.subnodes.atom;
93  for i=1:length(Tatom)
94  coords = [coords; str2num(Tatom{i}.x3) str2num(Tatom{i}.y3) str2num(Tatom{i}.z3)];
95  %elmtxv(i) = get_atomindex(Tatom{i}.elementType);
96  spxv(i,:) = Tatom{i}.elementType;
97  elmtxv(i) = 71;
98  end
99  xml_params.coordinates = coords;
100  xml_params.elmtxv = elmtxv;
101  xml_params.spxv = spxv;
102 
103  vect(1,:)=str2num(subnodes.lattice.subnodes.latticeVector{1}.value);
104  vect(2,:)=str2num(subnodes.lattice.subnodes.latticeVector{2}.value);
105  vect(3,:)=str2num(subnodes.lattice.subnodes.latticeVector{3}.value);
106 
107  %if module.subnodes.lattice.subnodes.latticeVector{1}.units == 'siestaUnits:angstrom' %THIS IS IN BOHR :|
108  if strcmp(subnodes.lattice.subnodes.latticeVector{1}.units,'siestaUnits:Ang')
109  coords = coords/Bohr;
110  vect=vect/Bohr;
111  end
112  xml_params.Lattice_vectors = vect;
113  end
114  %coords = coords*vect;
115 
116 
117  end
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
function Read_Siesta_XML(xmlfile, fields, readanyway)