2 %> @brief Parses the SIESTA XML output and looks
for relevant data
6 %> @
param 'xmlfile' the xml output of the SIESTA calculation.
7 %> @
param 'fields' what entries to read from the file.
10 %SOME CONSTANTS USED IN SIESTA
11 RytoeV = 1/13.60580; % Rydberg to eV
12 Bohr = 0.529177; % Angstrom
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])
22 tmp = read_SiestaXML( xmlfile, fields );
24 %%convert tmp to make in unfallable
25 if isfield(tmp,
'property')
26 if isstruct(tmp.property)
27 property{1} = tmp.property;
29 property = tmp.property;
35 if isfield(tmp,
'propertyList')
36 if isstruct(tmp.propertyList)
37 propertyList{1} = tmp.propertyList;
39 propertyList = tmp.propertyList;
45 if isfield(tmp,
'module')
46 module{1} = tmp.module;
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
59 for ik=1:length(Tkpoints)
60 kp(ik,1:4) = [str2num(Tkpoints{ik}.coords) str2num(Tkpoints{ik}.weight)];
63 xml_params.kpoints = kp;
68 %% READ FERMI ENERGY FROM FILE
70 for i=1:length(property)
71 if strcmp(property{i}.dictRef,
'siesta:E_Fermi')
72 EF = str2num(property{i}.subnodes.scalar.value);
74 xml_params.E_Fermi = EF;
79 %% READ K-SUPERCELL SIZE FROM FILE
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]);
88 %COORDS and %LATTICE VECTORS
90 subnodes = module{1}.subnodes;
92 Tatom=subnodes.molecule.subnodes.atomArray.subnodes.atom;
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;
99 xml_params.coordinates = coords;
100 xml_params.elmtxv = elmtxv;
101 xml_params.spxv = spxv;
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);
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;
112 xml_params.Lattice_vectors = vect;
114 %coords = coords*vect;
Structure param contains data structures describing the physical parameters of the scattering center ...
function Read_Siesta_XML(xmlfile, fields, readanyway)