2 % Copyright (C) 2009-2017 Peter Rakyta, Ph.D.
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.
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.
14 % You should have received a copy of the GNU General Public License
15 % along with
this program. If not, see http:
17 %> @addtogroup filters Filters
20 %> @brief This
function is an input filter that parses XML file and fills up the parameter
structures necessary to initialize EQuUs classes.
22 %> @brief This
function is an input filter that parses XML file and fills up the parameter
structures necessary to initialize EQuUs classes.
23 %> @
param filename A
string containing the filename of the XML file.
24 %> @
return [1] An instance of structure #
Opt 25 %> @
return [2] An instance of structure #
param 30 parameter_names = {
'Decimation',
'Decimation_block',
'magnetic_field',
'magnetic_field_trans_invariant',
'Lattice_Type', ...
31 'Simple_Green_Function',
'Linear_Regression_in_B',
'BdG',
'Spin',
'Silent',
'usingDualModes',
'debug',
'workers',
'custom_Hamiltonians',
'WorkingDir' };
39 % check data consistency like LeadNum, orientation VS Lead_orientation
47 Opt.Decimation_block = 151;
49 Opt.magnetic_field = 0;
50 Opt.magnetic_field_trans_invariant = true;
51 Opt.Lattice_Type = [];
52 Opt.Simple_Green_Function = 0;
53 Opt.Linear_Regression_in_B = 1;
57 Opt.usingDualModes = 1;
60 Opt.custom_Hamiltonians = [];
64 % skeletons for physical parameters of the scattering region and leads
65 param.scatter = struct();
69 param.Leads = cell(0);
74 %> @brief This opens the XML file and fills up the parameter
structures 75 %> @
param filename A
string containing the filename of the XML file.
79 if cCommonFunctions.isOctave()
80 parser = javaObject('org.apache.xerces.parsers.DOMParser');
81 parser.parse(filename);
82 tree = parser.getDocument;
84 tree = xmlread(filename);
93 %> @brief This
function parses over the attributes of the tree node
94 %> @
param theNode An instance of XML DOM node.
96 % Recurse over node children.
98 if theNode.hasChildNodes
99 childNodes = theNode.getChildNodes;
100 numChildNodes = childNodes.getLength;
106 for count = 1:numChildNodes
107 theChild = childNodes.item(count-1);
109 if strcmpi(
char(theChild.getNodeName), 'parameters' )
111 elseif strcmpi(
char(theChild.getNodeName), 'computing_parameters' )
113 elseif strcmpi(
char(theChild.getNodeName), 'Scatter_region' )
115 elseif strcmpi(
char(theChild.getNodeName), 'Lead_parameters' )
121 %children(count) = makeStructFromNode(theChild);
126 %> @brief This
function sets computing parameters in the structure
#Opt 127 %> @
param theNode An instance of XML DOM node.
129 if theNode.hasChildNodes
130 childNodes = theNode.getChildNodes;
131 numChildNodes = childNodes.getLength;
136 for count = 1:numChildNodes
137 theChild = childNodes.item(count-1);
139 if ismember(
char(theChild.getNodeName), parameter_names )
141 setOptValue( attributes,
char(theChild.getNodeName) )
148 %% setScatterParameter
149 %> @brief This
function sets parameters for the scattering region
150 %> @
param theNode An instance of XML DOM node.
152 if theNode.hasChildNodes
153 childNodes = theNode.getChildNodes;
154 numChildNodes = childNodes.getLength;
159 for count = 1:numChildNodes
160 theChild = childNodes.item(count-1);
162 if ismember(
char(theChild.getNodeName), parameter_names )
164 setOptValue( attributes,
char(theChild.getNodeName) )
165 elseif strcmpi(
char(theChild.getNodeName), '
shape' )
167 elseif strcmpi(
char(theChild.getNodeName), '
Atom' )
177 %> @brief This
function creates a structure
Atom consisting of the atomic data of the
sites 178 %> @
param theNode A node of an XML DOM.
179 %> @return Returns with the modificated parameter structure
182 % determine, whether the node has child nodes or not
183 if ~theNode.hasChildNodes
187 % initialize cell array of Atoms if necessary
188 if ~isfield(param_structure, '
Atom') || isempty( param_structure.
Atom )
192 % determine the new length of the cell array
193 atom_idx = length( param_structure.
Atom ) + 1;
196 % determine the new length of the cell array
197 % atom_idx = length( param_structure.
Atom ) + 1;
200 childNodes = theNode.getChildNodes;
201 numChildNodes = childNodes.getLength;
203 for count = 1:numChildNodes
204 theChild = childNodes.item(count-1);
206 if strcmpi(
char(theChild.getNodeName), 'PL' )
207 % the principal layer
209 param_structure.
Atom(atom_idx).PL = str2double(attributes.value);
210 elseif strcmpi(
char(theChild.getNodeName), 'Id' )
211 % the identification umber
213 param_structure.
Atom(atom_idx).Id = str2double(attributes.value);
221 %> @brief This
function creates structure
shape for the scattering region
222 %> @
param theNode A node of an XML DOM.
223 %> @return Returns with the modificated parameter structure
225 if theNode.hasChildNodes
226 childNodes = theNode.getChildNodes;
227 numChildNodes = childNodes.getLength;
234 for count = 1:numChildNodes
235 theChild = childNodes.item(count-1);
237 if strcmpi(
char(theChild.getNodeName), 'width' )
239 shape.width = str2double( attributes.value );
240 elseif strcmpi(
char(theChild.getNodeName), 'height' )
242 shape.height = str2double( attributes.value );
251 %> @brief This
function sets parameters of the Leads
252 %> @
param theNode A node of an XML DOM.
253 %> @return Returns with a cell array of lead parameters
255 if theNode.hasChildNodes
256 childNodes = theNode.getChildNodes;
257 numChildNodes = childNodes.getLength;
262 % do a for loop to cover all the leads
263 for count = 1:numChildNodes
264 theChild = childNodes.item(count-1);
266 if strcmpi(
char(theChild.getNodeName), 'lead' )
268 elseif strcmpi(
char(theChild.getNodeName), 'NofLeads' )
270 setOptValue( attributes,
char(theChild.getNodeName) )
279 %> @brief This
function fills up data from one particular lead node
280 %> @
param theNode A node of an XML DOM.
281 %> @
param Leads A cell array of lead parameters.
282 %> @return Returns with the updated cell array of lead parameters.
285 num = str2double(lead_attributes.num);
293 if theNode.hasChildNodes
294 childNodes = theNode.getChildNodes;
295 numChildNodes = childNodes.getLength;
302 for count = 1:numChildNodes
303 theChild = childNodes.item(count-1);
305 if strcmpi(
char(theChild.getNodeName),
'Atom' )
319 %> @brief This sets a value
for a field in the
Opt structure
320 %> @
param attributes A sata structure extracted from the XML DOM node.
321 %> @
param attribname String of the attribute name to be set
324 if ( isfield( attributes,
'value') )
325 if ~isnan( str2double( attributes.(
'value') ) )
326 Opt.( attribname ) = str2double( attributes.(
'value') );
328 Opt.( attribname ) = attributes.(
'value');
331 display([
'bad attribute: ', attribname ])
337 %> @brief This
function sets a value
for a field in the #param_structure
338 %> @
param param_structure Data structure containing the physical parameters
339 %> @
param node An instance of XML DOM node.
340 %> @
return Returns with the updated structure of parameters
341 function param_structure =
setParamValue( param_structure, node )
345 if isfield( attributes,
'value' )
346 % make a difference between character and numeric type values (
if the type of the input parameter was mistaken or missing)
347 value = str2double(attributes.value);
349 param_structure.(char(node.getNodeName)) = attributes.value;
351 param_structure.(char(node.getNodeName)) = value;
354 elseif isfield( attributes,
'abs' ) && isfield( attributes,
'phase' )
355 param_structure.(
char(node.getNodeName)) = str2double(attributes.abs)*exp(1i*str2double(attributes.phase));
363 %> @brief This
function parses the attributes of the XML node
364 %> @
param theNode An instance of XML DOM node.
365 %> @return Returns with the structure of the extracted parameters
367 % Create attributes structure.
370 if theNode.hasAttributes
371 theAttributes = theNode.getAttributes;
372 numAttributes = theAttributes.getLength;
373 attributes = struct();
378 for count = 1:numAttributes
379 attrib = theAttributes.item(count-1);
380 attributes.(
char(attrib.getName) ) =
char(attrib.getValue);
Structure Atom contains the atomic identifiers of the sites.
Structure Opt contains the basic computational parameters used in EQuUs.
Structure shape contains data about the geometry of the scattering region.
function Transport(Energy, B)
Calculates the conductance at a given energy value.
A class providing function handle to reduce the number of sites in the Hamiltonian via decimation pro...
A class containing common basic functionalities.
Structure param contains data structures describing the physical parameters of the scattering center ...
Structure sites contains data to identify the individual sites in a matrix.
function ValidateStructures(Opt, param)
This function verify the input structures Opt and param and create system specific data structures.
function structures(name)