Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
XMLoutput.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - XMLoutput
2 % Copyright (C) 2009-2017 Peter Rakyta, Ph.D.
3 %
4 % This program is free software: you can redistribute it and/or modify
5 % it under the terms of the GNU General Public License as published by
6 % the Free Software Foundation, either version 3 of the License, or
7 % (at your option) any later version.
8 %
9 % This program is distributed in the hope that it will be useful,
10 % but WITHOUT ANY WARRANTY; without even the implied warranty of
11 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 % GNU General Public License for more details.
13 %
14 % You should have received a copy of the GNU General Public License
15 % along with this program. If not, see http://www.gnu.org/licenses/.
16 %
17 % This function is the output filter to generate XML file from the
18 % running parameters.
19 %%
20 function XMLoutput( filename, Opt, param )
21 
22 
23 descriptions = struct( ...
24  'Decimation', 'Option for using Decimation. Type 1,2 or 3 to use it, 0 to not use it', ...
25  'Decimation_block', 'size of maximal block to decimate', ...
26  'magnetic_field', 'Type 0 not to use magnetic field, or 1 to use magnetic field', ...
27  'magnetic_field_trans_invariant', 'Set true (default) if a magnetic field is translational invariant along the scattering center, or false otherwise.', ...
28  'Lattice_Type', 'Stirng containing the lattice type. See the documantation.', ...
29  'Simple_Green_Function', 'Set 1 if a simple analytical surface Greens function computational method is about to use. (Only for square lattice without a magnetic field) ', ...
30  'Linear_Regression_in_B', 'Set to 1 to use linear regression to calculate peierls integrals between the sites. Useful when dealing with homogenius magnetic field', ....
31  'BdG', 'Set 1 to use the Bogoliubov de Gennes model, or 0 for normal system. ', ...
32  'Spin', 'Set 1 to include electron spin in the computations, or 0 otherwise. ', ...
33  'Silent', 'Set to 1 in order to supress output messages', ...
34  'usingDualModes', 'Set 1 to use dual modes in the calculations, or 0 to use the left and right sided eigenvectors instead. ', ...
35  'debug', 'Set 1 to export debug informations into the debug.txt file, or 0 otherwise.', ...
36  'workers', 'Number of the workers in the parallel for loops', ...
37  'custom_Hamiltonians', 'The identifier of the external source of Hamiltonians. See the documentation for details.', ...
38  'computing_parameters', 'Parameters used in calculations', ...
39  'Scatter_region', 'Parameters used to create scattering region', ...
40  'epsilon', 'On-site energy', ...
41  'vargamma', 'Hopping amplitude', ...
42  'vargamma2', 'Hopping amplitude', ...
43  'vargamma3', 'Hopping amplitude', ...
44  'pair_potential', 'Superconducting pair potential, with abs standing for the absolute value and phase for the phase of the complex number', ...
45  'End_Type', 'Lead end type in case of hexagonal lattice', ...
46  'Lead_parameters', 'Physical parameters of the individual leads.', ...
47  'NofLeads', 'Number of leads', ...
48  'vargamma_sc', 'Alternative hopping to the scattering reigon' , ...
49  'orientation', 'Orientation of the lead', ...
50  'lead', 'Physical parameters of a lead.' , ...
51  'shape', 'Dimensions of the scattering region', ...
52  'width', 'Width of the scattering center', ...
53  'height', 'length (height) of the scattering center' ,...
54  'M', 'Number of sites in the cross section of the lead', ...
55  'AtomNode', 'Description of an atomic site',...
56  'PL', 'Index of the principal layer',...
57  'Id', 'Identification number of the site',...
58  'Lead_Orientation', 'Orientation of the lead.' ...
59  );
60 
61 cCommonFunctions = CommonFunctions();
62 
63 XMLtree = [];
64 root = [];
65 
69 setLeads();
70 
71 cCommonFunctions.xmlwrite( filename, XMLtree );
72 
73 
74 
75 %% SetRoot element
76  function setRootElement()
77 
78  if cCommonFunctions.isOctave()
79  % Create a Xerces DOM document object
80  XMLtree = javaObject ('org.apache.xerces.dom.DocumentImpl');
81  % Append a root node to the document
82  XMLtree.appendChild (XMLtree.createElement ('parameters'));
83  else
84 
85  XMLtree = com.mathworks.xml.XMLUtils.createDocument('parameters');
86  end
87  root = XMLtree.getDocumentElement;
88  root.setAttribute('identifier', cCommonFunctions.getProgramShortName() );
89  root.setAttribute('version', num2str( cCommonFunctions.getVersion() ) );
90 
91  end
92 
93 
94 %% SetComputingParameters
96  computing_parametersNode = XMLtree.createElement('computing_parameters');
97  computing_parametersNode.setAttribute('description', descriptions.computing_parameters);
98 
99 
100  fieldnamesOpt = fieldnames( Opt );
101  for idx = 1:length(fieldnamesOpt)
102  fieldname = fieldnamesOpt{idx};
103  if isempty( Opt.(fieldname) )
104  continue
105  end
106 
107  XMLnode = createXMLnode( fieldname, Opt );
108  computing_parametersNode.appendChild(XMLnode);
109 
110  end
111 
112  root.appendChild(computing_parametersNode);
113 
114  end
115 
118  if isempty( param.scatter)
119  return
120  end
121 
122  nodename = 'Scatter_region';
123  Scatter_regionNode = XMLtree.createElement( nodename );
124  Scatter_regionNode.setAttribute('description', descriptions.(nodename));
125 
126  fieldnamesScatter = fieldnames( param.scatter );
127  for idx = 1:length( fieldnamesScatter)
128  fieldname = fieldnamesScatter{idx};
129  if isempty( param.scatter.(fieldname) )
130  continue
131  end
132 
133  if strcmp( fieldname, 'shape' )
134  shapeNodeName = 'shape';
135  ShapeNode = XMLtree.createElement( shapeNodeName );
136  ShapeNode.setAttribute('description', descriptions.(shapeNodeName));
137 
138  if isempty( param.scatter.shape )
139  continue
140  elseif isempty( param.scatter.shape.width )
141  continue
142  elseif isempty( param.scatter.shape.height )
143  continue
144  end
145 
146  fieldnamesShape = fieldnames( param.scatter.shape );
147  for jdx = 1:length( fieldnamesShape)
148  fieldnameShape = fieldnamesShape{jdx};
149  XMLnode = createXMLnode( fieldnameShape, param.scatter.shape );
150  ShapeNode.appendChild(XMLnode);
151  end
152 
153  Scatter_regionNode.appendChild(ShapeNode);
154  elseif strcmp( fieldname, 'Atom' )
155  if isempty( param.scatter.Atom )
156  continue
157  end
158  appendAtomNodes( param.scatter.Atom, Scatter_regionNode )
159  else
160  XMLnode = createXMLnode( fieldname, param.scatter );
161  Scatter_regionNode.appendChild(XMLnode);
162  end
163 
164 
165  end
166 
167  root.appendChild(Scatter_regionNode);
168  end
169 %% setLeads();
171  if isempty( param.Leads)
172  return
173  end
174 
175  nodename = 'Lead_parameters';
176  LeadsNode = XMLtree.createElement( nodename );
177  LeadsNode.setAttribute('description', descriptions.(nodename));
178 
179  XMLnode = XMLtree.createElement( 'NofLeads' );
180  XMLnode.setAttribute('value', num2str(length(param.Leads)));
181  XMLnode.setAttribute('description', descriptions.('NofLeads'));
182  LeadsNode.appendChild(XMLnode);
183 
184  for idx = 1:length(param.Leads)
185  setLead( idx )
186  end
187 
188  root.appendChild(LeadsNode);
189 
190  % set individual leads
191  function setLead( leadnum )
192  leadnodename = 'lead';
193  LeadNode = XMLtree.createElement( leadnodename );
194  LeadNode.setAttribute('num', num2str(leadnum));
195 
196  fieldnamesLead = fieldnames( param.Leads{leadnum} );
197  for jdx = 1:length( fieldnamesLead)
198  fieldname = fieldnamesLead{jdx};
199  if isempty( param.Leads{leadnum}.(fieldname) )
200  continue
201  end
202 
203  if strcmp( fieldname, 'Atom' )
204  if isempty( param.scatter.Atom )
205  continue
206  end
207  appendAtomNodes( param.Leads{leadnum}.Atom, LeadNode );
208  else
209 
210  XMLnode = createXMLnode( fieldname, param.Leads{leadnum} );
211  LeadNode.appendChild(XMLnode);
212  end
213  end
214 
215  LeadsNode.appendChild(LeadNode);
216 
217 
218  end
219 
220 
221 
222  end
223 
224 
225 
226 
228  function appendAtomNodes( structure, parentXMLnode )
229 
230  AtomNodeName = 'Atom';
231  numAtoms = length( structure );
232  for jdx = 1:numAtoms
233  AtomNode = XMLtree.createElement( AtomNodeName );
234  AtomNode.setAttribute('description', descriptions.AtomNode);
235 
236  if isempty( structure )
237  continue
238  end
239 
240  fieldnamesAtom = fieldnames( structure(jdx) );
241  for kdx = 1:length( fieldnamesAtom)
242  fieldnameAtom = fieldnamesAtom{kdx};
243  XMLnode = createXMLnode( fieldnameAtom, structure(jdx) );
244  XMLnode.setAttribute('description', descriptions.(fieldnameAtom));
245  AtomNode.appendChild(XMLnode);
246  end
247  parentXMLnode.appendChild(AtomNode);
248  end
249 
250  end
251 
252 
253 
254 %% createXMLNode
255  function XMLnode = createXMLnode( fieldname, structure )
256  XMLnode = XMLtree.createElement( fieldname );
257  if ischar( structure.(fieldname) )
258  paramval = structure.(fieldname);
259  XMLnode.setAttribute('value', paramval);
260  elseif isscalar( structure.(fieldname) ) && isreal(structure.(fieldname))
261  paramval = num2str( structure.(fieldname) );
262  XMLnode.setAttribute('value', paramval);
263  elseif isscalar( structure.(fieldname) ) && ~isreal(structure.(fieldname))
264  absval = num2str( abs(structure.(fieldname) ));
265  angleval = num2str( angle(structure.(fieldname) ));
266  XMLnode.setAttribute('abs', absval);
267  XMLnode.setAttribute('phase', angleval);
268  else
269  return
270  end
271 
272 
273  if isfield( descriptions, fieldname )
274  XMLnode.setAttribute('description', descriptions.(fieldname));
275  end
276 
277  end
278 
279 
280 end
Structure Atom contains the atomic identifiers of the sites.
Definition: structures.m:148
function appendAtomNodes(structure, parentXMLnode)
lead_param Leads
A list of structures lead_param containing the physical parameters for the scattering region.
Definition: structures.m:49
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:60
Structure shape contains data about the geometry of the scattering region.
Definition: structures.m:106
function Transport(Energy, B)
Calculates the conductance at a given energy value.
function setRootElement()
function setLeads()
function setScatteringRegion()
A class containing common basic functionalities.
function()
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
function createXMLnode(fieldname, structure)
function setLead(leadnum)
scatter_param scatter
An instance of the structure scatter_param containing the physical parameters for the scattering regi...
Definition: structures.m:47
function setComputingParameters()
function XMLoutput(filename, Opt, param)