-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrnfoundry_release.m
255 lines (213 loc) · 7.91 KB
/
rnfoundry_release.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
function rnfoundry_release (varargin)
% perform tasks necessary for a release of the renewnet foundry
options.W64CrossBuildMexLibsDir = fullfile ('/home', 'rcrozier', 'Sync', 'work', 'matlab_windows_libs', ...
[ 'r', version('-release') ], ...
'extern', 'lib', 'win64', 'mingw64');
options.RunTests = false;
options.Version = 'devel';
options.MBDynVersion = '';
options.EWSTVersion = '';
options.ThrowBuildErrors = true;
options.Verbose = false;
options.W64CrossBuild = false;
options = parse_pv_pairs (options, varargin);
if isempty (options.MBDynVersion)
options.MBDynVersion = options.Version;
end
if isempty (options.EWSTVersion)
options.EWSTVersion = options.Version;
end
thisfilepath = fileparts (which ('rnfoundry_setup'));
addpath (thisfilepath);
% first build the linux mex fles etc.
rnfoundry_setup ( 'ForceAllMex', true, ...
'Verbose', true, ...
'RunTests', options.RunTests, ...
'PreventXFemmCheck', true, ...
'ThrowBuildErrors', true, ...
'Verbose', options.Verbose );
if options.W64CrossBuild
% now build the windows mex fles etc.
[ MBCLibDir, MBCIncludeDir ] = mbdyn.mint.find_libmbc ('ForceLocalDirsOnlyForArch', 'win64');
rnfoundry_setup ( 'ForceAllMex', true, ...
'W64CrossBuild', true, ...
'W64CrossBuildMexLibsDir', options.W64CrossBuildMexLibsDir, ...
'MBCLibDir', MBCLibDir, ...
'MBCIncludeDir', MBCIncludeDir, ...
'PreventXFemmCheck', true, ...
'ThrowBuildErrors', true, ...
'Verbose', options.Verbose );
end
exampledirs = {};
if exist ('help2rst', 'file')
% now build the documentation
rndocdir = fullfile (thisfilepath, 'documentation');
mkdir (rndocdir);
[ mbdyndocrootdir, mbdyndoczipfilename ] = mbdyn.makedocs ('Version', options.MBDynVersion);
% movefile ( fullfile (mbdyndocrootdir, '..', mbdyndoczipfilename), ...
% rndocdir );
unzip (fullfile (mbdyndocrootdir, '..', mbdyndoczipfilename), rndocdir);
[ ewstdocrootdir, ewstdoczipfilename ] = wsim.makedocs ('Version', options.EWSTVersion);
% movefile ( fullfile (ewstdocrootdir, '..', ewstdoczipfilename), ...
% rndocdir );
unzip (fullfile (ewstdocrootdir, '..', ewstdoczipfilename), rndocdir);
end
% create the readme files
help2txtfile (fullfile (thisfilepath, 'README.txt'), 'rnfoundry_release>readme');
help2txtfile (fullfile (thisfilepath, 'README.rst'), 'rnfoundry_release>readme');
end
function readme ()
% RENEWNET FOUNRDY
% ****************
%
% The renewnet foundry is a set of matlab codes and other software
% aimed at the simulation of renewable energy systems, including
% development of the power take-off components. The most well
% developed parts of the foundry are the multibody dynamics tools,
% wave systems tools and the permanent magnet machine design and
% simulation tools.
%
% Most code in the foundry is also compatible with Octave, the free
% alternative to Matlab.
%
% INSTALLATION
% ============
%
% To get started with the matlab code you should run the function::
%
% rnfoundry_setup
%
% found in the top level directory. It is also advised that you
% READ THE HELP FOR THIS FUNCTION before running it to get an idea
% of what it does and what the system requirements are to get
% optimum performance. Ideally you will have a C++ compiler set up
% with your matlab installation, see the rnfoundry_setup help for
% more information. Other than this the setup is fully automated.
%
% USAGE
% =====
%
% Documentation for some parts of the Renewnet Foundry is provided
% in html (web page) format in the top level 'documentation'
% directory.
%
% You can find some example scripts in the following directories:
%
% Edinburgh Wave Systems Toolbox
% ------------------------------
%
% rnfoundry/wave/doc/sphinx/examples
%
% This contains examples of using the Edinburgh Wave Systems Toolbox.
% Further (less refined and well commented) examples of using this may
% be found in
%
% rnfoundry/wave/matlab-octave/wec-sim/test
%
%
% MBdyn Multibody Dynamics Toolbox
% --------------------------------
%
% rnfoundry/common/multibody/MBDyn/doc/sphinx/examples
%
% Further (less refined and commented) examples can be found in the
% testing code in
%
% rnfoundry/common/multibody/MBDyn/test
%
%
% Permanent Magnet Machines Toolbox
% ---------------------------------
%
% rnfoundry/common/electrical/matlab-octave/permanent_magnet_machines_tools/examples_and_tutorials
%
% Contains examples of using the permanent magnet machine simulation
% tools
end
function params = parse_pv_pairs(params,pv_pairs)
% parse_pv_pairs: parses sets of property value pairs, allows defaults
% usage: params=parse_pv_pairs(default_params,pv_pairs)
%
% arguments: (input)
% default_params - structure, with one field for every potential
% property/value pair. Each field will contain the default
% value for that property. If no default is supplied for a
% given property, then that field must be empty.
%
% pv_array - cell array of property/value pairs.
% Case is ignored when comparing properties to the list
% of field names. Also, any unambiguous shortening of a
% field/property name is allowed.
%
% arguments: (output)
% params - parameter struct that reflects any updated property/value
% pairs in the pv_array.
%
% Example usage:
% First, set default values for the parameters. Assume we
% have four parameters that we wish to use optionally in
% the function examplefun.
%
% - 'viscosity', which will have a default value of 1
% - 'volume', which will default to 1
% - 'pie' - which will have default value 3.141592653589793
% - 'description' - a text field, left empty by default
%
% The first argument to examplefun is one which will always be
% supplied.
%
% function examplefun(dummyarg1,varargin)
% params.Viscosity = 1;
% params.Volume = 1;
% params.Pie = 3.141592653589793
%
% params.Description = '';
% params=parse_pv_pairs(params,varargin);
% params
%
% Use examplefun, overriding the defaults for 'pie', 'viscosity'
% and 'description'. The 'volume' parameter is left at its default.
%
% examplefun(rand(10),'vis',10,'pie',3,'Description','Hello world')
%
% params =
% Viscosity: 10
% Volume: 1
% Pie: 3
% Description: 'Hello world'
%
% Note that capitalization was ignored, and the property 'viscosity'
% was truncated as supplied. Also note that the order the pairs were
% supplied was arbitrary.
npv = length(pv_pairs);
n = npv/2;
if n~=floor(n)
error 'Property/value pairs must come in PAIRS.'
end
if n<=0
% just return the defaults
return
end
if ~isstruct(params)
error 'No structure for defaults was supplied'
end
% there was at least one pv pair. process any supplied
propnames = fieldnames(params);
lpropnames = lower(propnames);
for i=1:n
p_i = lower(pv_pairs{2*i-1});
v_i = pv_pairs{2*i};
ind = strmatch(p_i,lpropnames,'exact');
if isempty(ind)
ind = find(strncmp(p_i,lpropnames,length(p_i)));
if isempty(ind)
error(['No matching property found for: ',pv_pairs{2*i-1}])
elseif length(ind)>1
error(['Ambiguous property name: ',pv_pairs{2*i-1}])
end
end
p_i = propnames{ind};
% override the corresponding default in params
params = setfield(params,p_i,v_i);
end
end