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' };
39 % check data consistency like LeadNum, orientation VS Lead_orientation
42 %> @brief This function sets default values to the parameter
structures 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
180 function param_structure =
createAtom( theNode, param_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 childNodes = theNode.getChildNodes;
197 numChildNodes = childNodes.getLength;
199 for count = 1:numChildNodes
200 theChild = childNodes.item(count-1);
202 if strcmpi(
char(theChild.getNodeName), 'PL' )
203 % the principal layer
205 param_structure.
Atom(atom_idx).PL = str2double(attributes.value);
206 elseif strcmpi(
char(theChild.getNodeName), 'Id' )
207 % the identification umber
209 param_structure.
Atom(atom_idx).Id = str2double(attributes.value);
217 %> @brief This function creates structure
shape for the scattering region
218 %> @
param theNode A node of an XML DOM.
219 %> @return Returns with the modificated parameter structure
220 function param_structure =
createShape( theNode, param_structure )
221 if theNode.hasChildNodes
222 childNodes = theNode.getChildNodes;
223 numChildNodes = childNodes.getLength;
230 for count = 1:numChildNodes
231 theChild = childNodes.item(count-1);
233 if strcmpi(
char(theChild.getNodeName), 'width' )
235 shape.width = str2double( attributes.value );
236 elseif strcmpi(
char(theChild.getNodeName), 'height' )
238 shape.height = str2double( attributes.value );
247 %> @brief This function sets parameters of the Leads
248 %> @
param theNode A node of an XML DOM.
249 %> @return Returns with a cell array of lead parameters
251 if theNode.hasChildNodes
252 childNodes = theNode.getChildNodes;
253 numChildNodes = childNodes.getLength;
258 % do a for loop to cover all the leads
259 for count = 1:numChildNodes
260 theChild = childNodes.item(count-1);
262 if strcmpi(
char(theChild.getNodeName), 'lead' )
264 elseif strcmpi(
char(theChild.getNodeName), 'NofLeads' )
266 setOptValue( attributes,
char(theChild.getNodeName) )
275 %> @brief This function fills up data from one particular lead node
276 %> @
param theNode A node of an XML DOM.
277 %> @
param Leads A cell array of lead parameters.
278 %> @return Returns with the updated cell array of lead parameters.
281 num = str2double(lead_attributes.num);
289 if theNode.hasChildNodes
290 childNodes = theNode.getChildNodes;
291 numChildNodes = childNodes.getLength;
298 for count = 1:numChildNodes
299 theChild = childNodes.item(count-1);
310 %> @brief This sets a value
for a field in the
Opt structure
311 %> @
param attributes A sata structure extracted from the XML DOM node.
312 %> @
param attribname String of the attribute name to be set
315 if ( isfield( attributes,
'value') )
316 if ~isnan( str2double( attributes.(
'value') ) )
317 Opt.( attribname ) = str2double( attributes.(
'value') );
319 Opt.( attribname ) = attributes.(
'value');
322 display([
'bad attribute: ', attribname ])
328 %> @brief This
function sets a value
for a field in the #param_structure
329 %> @
param param_structure Data structure containing the physical parameters
330 %> @
param node An instance of XML DOM node.
331 %> @
return Returns with the updated structure of parameters
332 function param_structure =
setParamValue( param_structure, node )
336 if isfield( attributes,
'value' )
337 % make a difference between character and numeric type values (
if the type of the input parameter was mistaken or missing)
338 value = str2double(attributes.value);
340 param_structure.(char(node.getNodeName)) = attributes.value;
342 param_structure.(char(node.getNodeName)) = value;
345 elseif isfield( attributes,
'abs' ) && isfield( attributes,
'phase' )
346 param_structure.(
char(node.getNodeName)) = str2double(attributes.abs)*exp(1i*str2double(attributes.phase));
354 %> @brief This function parses the attributes of the XML node
355 %> @
param theNode An instance of XML DOM node.
356 %> @return Returns with the structure of the extracted parameters
358 % Create attributes structure.
361 if theNode.hasAttributes
362 theAttributes = theNode.getAttributes;
363 numAttributes = theAttributes.getLength;
364 attributes = struct();
369 for count = 1:numAttributes
370 attrib = theAttributes.item(count-1);
371 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)