Eötvös Quantum Utilities  v4.8.128
Providing the Horsepowers in the Quantum Realm
XMLinput.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - XMLinput
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 input filter to generate running parameters from
18 % XML file.
19 %%
20 function [Opt, param] = XMLinput( filename )
21 
22 
23 Opt = structures('Opt');
24 param = structures('param');
25 
26 parameter_names = { 'Decimation', 'Decimation_block', 'magnetic_field', 'magnetic_field_trans_invariant', 'Lattice_Type', ...
27  'Simple_Green_Function', 'Linear_Regression_in_B', 'BdG', 'Spin', 'Silent', 'usingDualModes', 'debug', 'workers', 'custom_Hamiltonians' };
28 
30 parseXML( filename )
31 
32 % Old format of lattice types
33 if Opt.Lattice_Type == 0
34  Opt.Lattice_Type = 'Square';
35 elseif Opt.Lattice_Type == 1
36  Opt.Lattice_Type = 'Graphene';
37 elseif Opt.Lattice_Type == 2
38  Opt.Lattice_Type = 'Silicene';
39 end
40 
41  %% setDefaults
42  % This sets default values to the parameter structures
43  function setDefaults()
44 
45  Opt = structures('Opt');
46  Opt.Decimation = 4;
47  Opt.Decimation_block = 151;
48  Opt.NofLeads = 0;
49  Opt.magnetic_field = 0;
50  Opt.magnetic_field_trans_invariant = true;
51  Opt.Lattice_Type = []; %New default value
52  Opt.Simple_Green_Function = 0;
53  Opt.Linear_Regression_in_B = 1;
54  Opt.BdG = 0;
55  Opt.Spin = 0;
56  Opt.Silent = 0;
57  Opt.usingDualModes = 1;
58  Opt.debug = 0;
59  Opt.workers = [];
60  Opt.custom_Hamiltonians = [];
61 
62  param = structures('param');
63  param.scatter = structures('scatter_param');
64  param.scatter.epsilon = 0;
65  param.scatter.vargamma = 0;
66  param.scatter.shape = structures('shape');
67  param.scatter.Overlap_in_Scatter = 0;
68 
69  param.Leads = cell(0);
70 
71  end
72 
73  %% parseXML
74  % This opens the XML file and fills up the parameter structures
75  function parseXML(filename)
76 
77  cCommonFunctions = CommonFunctions();
78  if cCommonFunctions.isOctave()
79  parser = javaObject('org.apache.xerces.parsers.DOMParser');
80  parser.parse(filename);
81  tree = parser.getDocument;
82  else
83  tree = xmlread(filename);
84  end
85 
86  traverseNodes( tree );
87 
88  end
89 
90 
91  %% traverseNodes
92  % This parses over the attributes of the tree node
93  function traverseNodes( theNode )
94  % Recurse over node children.
95 
96  if theNode.hasChildNodes
97  childNodes = theNode.getChildNodes;
98  numChildNodes = childNodes.getLength;
99  else
100  return
101  end
102 
103 
104  for count = 1:numChildNodes
105  theChild = childNodes.item(count-1);
106 
107  if strcmpi(char(theChild.getNodeName), 'parameters' )
108  traverseNodes( theChild )
109  elseif strcmpi(char(theChild.getNodeName), 'computing_parameters' )
110  setComputingParameters( theChild )
111  elseif strcmpi(char(theChild.getNodeName), 'Scatter_region' )
112  setScatterParameters( theChild )
113  elseif strcmpi(char(theChild.getNodeName), 'Lead_parameters' )
114  setLeadParameters( theChild )
115  end
116 
117 
118 
119  %children(count) = makeStructFromNode(theChild);
120  end
121  end
122 
124  % This sets computing parameters in the structures
125  function setComputingParameters( theNode )
126  if theNode.hasChildNodes
127  childNodes = theNode.getChildNodes;
128  numChildNodes = childNodes.getLength;
129  else
130  return
131  end
132 
133  for count = 1:numChildNodes
134  theChild = childNodes.item(count-1);
135 
136  if ismember(char(theChild.getNodeName), parameter_names )
137  attributes = parseAttributes(theChild);
138  setOptValue( attributes, char(theChild.getNodeName) )
139  end
140  end
141 
142  end
143 
144 
145  %% setScatterParameter
146  % This sets parameters for the scattering region
147  function setScatterParameters( theNode )
148  if theNode.hasChildNodes
149  childNodes = theNode.getChildNodes;
150  numChildNodes = childNodes.getLength;
151  else
152  return
153  end
154 
155  for count = 1:numChildNodes
156  theChild = childNodes.item(count-1);
157 
158  if ismember(char(theChild.getNodeName), parameter_names )
159  attributes = parseAttributes(theChild);
160  setOptValue( attributes, char(theChild.getNodeName) )
161  elseif strcmpi(char(theChild.getNodeName), 'shape' )
162  createShape( theChild )
163  else
164  param.scatter = setParamValue( param.scatter, theChild );
165  end
166  end
167 
168  end
169 
170  %% createShap
171  % This creates shape for scattering region
172  function createShape( theNode )
173  if theNode.hasChildNodes
174  childNodes = theNode.getChildNodes;
175  numChildNodes = childNodes.getLength;
176  else
177  return
178  end
179 
180  shape = [];
181 
182  for count = 1:numChildNodes
183  theChild = childNodes.item(count-1);
184 
185  if strcmpi(char(theChild.getNodeName), 'width' )
186  attributes = parseAttributes( theChild );
187  shape.width = str2double( attributes.value );
188  elseif strcmpi(char(theChild.getNodeName), 'height' )
189  attributes = parseAttributes( theChild );
190  shape.height = str2double( attributes.value );
191  end
192  end
193 
194  param.scatter.shape = shape;
195  end
196 
197 
199  % This sets parameters for Leads
200  function setLeadParameters( theNode )
201  if theNode.hasChildNodes
202  childNodes = theNode.getChildNodes;
203  numChildNodes = childNodes.getLength;
204  else
205  return
206  end
207 
208  for count = 1:numChildNodes
209  theChild = childNodes.item(count-1);
210 
211  if strcmpi(char(theChild.getNodeName), 'lead' )
212  createLeadNode( theChild );
213 
214  end
215  end
216 
217  end
218 
219  %% createLeadNode
220  % This fills up data from one lead node
221  function createLeadNode( theNode )
222  lead_attributes = parseAttributes( theNode );
223  num = str2double(lead_attributes.num);
224 
225  try
226  params = param.Leads{num};
227  catch err
228  params = structures('lead_param');
229  end
230 
231  if theNode.hasChildNodes
232  childNodes = theNode.getChildNodes;
233  numChildNodes = childNodes.getLength;
234  else
235  return
236  end
237 
238 
239 
240  for count = 1:numChildNodes
241  theChild = childNodes.item(count-1);
242  params = setParamValue( params, theChild );
243  end
244 
245 
246  param.Leads{num} = params;
247 
248  end
249 
250 
251  %% setOptValue
252  % This sets a value for a field in the Opt structure
253  function setOptValue( attributes, attribname )
254 
255  if ( isfield( attributes, 'value') )
256  if ~isnan( str2double( attributes.('value') ) )
257  Opt.( attribname ) = str2double( attributes.('value') );
258  else
259  Opt.( attribname ) = attributes.('value');
260  end
261  else
262  display(['bad attribute: ', attribname ])
263  end
264 
265  end
266 
267  %% setParamValue
268  % This sets a value for a field in the Opt structure
269  function param_structure = setParamValue( param_structure, node )
270 
271  if strcmpi(char(node.getNodeName), 'epsilon' )
272  attributes = parseAttributes( node );
273  param_structure.epsilon = str2double(attributes.value);
274  elseif strcmpi(char(node.getNodeName), 'vargamma' )
275  attributes = parseAttributes( node );
276  param_structure.vargamma = str2double(attributes.value);
277  elseif strcmpi(char(node.getNodeName), 'vargamma_sc' )
278  attributes = parseAttributes( node );
279  param_structure.vargamma_sc = str2double(attributes.value);
280  elseif strcmpi(char(node.getNodeName), 'vargamma1' )
281  attributes = parseAttributes( node );
282  param_structure.vargamma1 = str2double(attributes.value);
283  elseif strcmpi(char(node.getNodeName), 'vargamma2' )
284  attributes = parseAttributes( node );
285  param_structure.vargamma2 = str2double(attributes.value);
286  elseif strcmpi(char(node.getNodeName), 'vargamma3' )
287  attributes = parseAttributes( node );
288  param_structure.vargamma3 = str2double(attributes.value);
289  elseif strcmpi(char(node.getNodeName), 'SOintrinsic' )
290  attributes = parseAttributes( node );
291  param_structure.SOintrinsic = str2double(attributes.value);
292  elseif strcmpi(char(node.getNodeName), 'deltaAB' )
293  attributes = parseAttributes( node );
294  param_structure.deltaAB = str2double(attributes.value);
295  elseif strcmpi(char(node.getNodeName), 'SO_rashba_intrinsic' )
296  attributes = parseAttributes( node );
297  param_structure.SO_rashba_intrinsic = str2double(attributes.value);
298  elseif strcmpi(char(node.getNodeName), 'pair_potential' )
299  attributes = parseAttributes( node );
300  if isfield( attributes, 'value' )
301  param_structure.pair_potential = str2double(attributes.value);
302  else
303  param_structure.pair_potential = str2double(attributes.abs)*exp(1i*str2double(attributes.phase));
304  end
305  elseif strcmpi(char(node.getNodeName), 'Overlap_in_Leads' )
306  attributes = parseAttributes( node );
307  param_structure.Overlap_in_Leads = str2double(attributes.value);
308  elseif strcmpi(char(node.getNodeName), 'Filename' )
309  attributes = parseAttributes( node );
310  param_structure.Filename = attributes.value;
311  elseif strcmpi(char(node.getNodeName), 'Atom' )
312  if isempty( param_structure.Atom )
313  param_structure.Atom = structures('Atom');
314  end
315 
316  atom_idx = length( param_structure.Atom ) + 1;
317 
318  if node.hasChildNodes
319  childNodes = node.getChildNodes;
320  numChildNodes = childNodes.getLength;
321 
322  for count = 1:numChildNodes
323  theChild = childNodes.item(count-1);
324 
325  if strcmpi(char(theChild.getNodeName), 'PL' )
326  attributes = parseAttributes( theChild );
327  param_structure.Atom(atom_idx).PL = str2double(attributes.value);
328  elseif strcmpi(char(theChild.getNodeName), 'Id' )
329  attributes = parseAttributes( theChild );
330  param_structure.Atom(atom_idx).Id = str2double(attributes.value);
331  end
332 
333  end
334 
335  end
336  elseif strcmpi(char(node.getNodeName), 'Lead_Orientation' ) || strcmpi(char(node.getNodeName), 'orientation' )
337  attributes = parseAttributes( node );
338  param_structure.Lead_Orientation = str2double(attributes.value);
339  elseif strcmpi(char(node.getNodeName), 'M' )
340  attributes = parseAttributes( node );
341  param_structure.M = str2double(attributes.value);
342  elseif strcmpi(char(node.getNodeName), 'End_Type' )
343  attributes = parseAttributes( node );
344  param_structure.End_Type = attributes.value;
345  end
346 
347  end
348 
349 
350 
351  %% parseAttributes
352  % This function parses the attributes of the XML node
353  % ----- Local function PARSEATTRIBUTES -----
354  function attributes = parseAttributes(theNode)
355  % Create attributes structure.
356 
357  attributes = [];
358  if theNode.hasAttributes
359  theAttributes = theNode.getAttributes;
360  numAttributes = theAttributes.getLength;
361  attributes = struct();
362  else
363  return
364  end
365 
366  for count = 1:numAttributes
367  attrib = theAttributes.item(count-1);
368  attributes.( char(attrib.getName) ) = char(attrib.getValue);
369  end
370 
371 
372  end
373 
374 end
Structure Atom contains the atomic identifiers of the sites.
Definition: structures.m:208
lead_param Leads
A list of structures lead_param containing the physical parameters for the scattering region...
Definition: structures.m:49
function parseXML(filename)
function parseAttributes(theNode)
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:120
Structure shape contains data about the geometry of the scattering region.
Definition: structures.m:166
Structure scatter_param contains the physical parameters describing the scattering region...
Definition: structures.m:54
function XMLinput(filename)
function setComputingParameters(theNode)
function Transport(Energy, B)
creating the Ribbon class representing the twoterminal setup
A class providing function handle to reduce the number of sites in the Hamiltonian via decimation pro...
Definition: Decimation.m:29
A class containing common basic functionalities.
function setDefaults()
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
function createLeadNode(theNode)
function traverseNodes(theNode)
function setLeadParameters(theNode)
function createShape(theNode)
function setParamValue(param_structure, node)
function setOptValue(attributes, attribname)
function structures(name)
function setScatterParameters(theNode)