openEMS & Octave

Install support for openEMS

Moderators: thorsten, sebastian

Youry
Posts: 51
Joined: Wed 22 Feb 2012, 12:50

Re: openEMS & Octave

Post by Youry » Thu 22 Mar 2012, 09:03

I am not sure what you ask for Octave editor.

But you can't have everything in one piece...

As I don't know your level in Octave I try to help...

In the command window (where you putted 1+1) you can also call some m-files, that the key.

This m-file contains many command line, it can be build with any text editor (I am using notpad+ which put nice color for command word, and variable and comment and so one, but it is up to you their is many, it seems you already have one, good).

Then you create a m-file, you should save it...
For example a file test.m
Contains :
1+1;

addpath('The directory where is the file')

In the octave windows you launch it by typping simply is name. -> test (enter)
It should appear 2...

Remember, the file expension is .m
Remember to put savepath command if you don't want type it all the time you lunch Octave. (also true for openEMS folder)

Use command 'quit' to close Octave nicely and be sure that all change of the pathname was done.

Maple and octave are completely different, you should pass some times only with Octave to handle it properly.
That really great software, good choice :D
Good luck,

thorsten
Posts: 1425
Joined: Mon 27 Jun 2011, 12:26

Re: openEMS & Octave

Post by thorsten » Thu 22 Mar 2012, 14:13

Hi Georg,

so far I don't see any problem, you just need to continue with steps 8-11)
This is loading some Tutorial into the GUI Octave Editor and "Run" it.

You can integrate the Editor into the Main GuiOctave by dragging it on the Main Windows.

You use WinXP ?

Of cource you can also just edit the m-files with any editor you like and just execute it in the Octave Command Window... like Youry explained...

Maybe you read a bit more about Matlab http://en.wikipedia.org/wiki/Matlab

regards
Thorsten

GeorgHuber
Posts: 16
Joined: Fri 16 Mar 2012, 18:06

Re: openEMS & Octave

Post by GeorgHuber » Thu 22 Mar 2012, 17:35

Dear Youry,

thank you for answering.

Well, I'm completely new to Octave, so I didn't know how important
Octave Editor is. Going by your answer, it is not that important.
(I always feel like a toddler about to go on its first trip to a doctor when
installing and using a big software package with interrelated parts for
the first time. It's a very unpleasant feeling. That's why I'm happy that
some people try to give a helping hand - or rather - helping mind.)

I will work by your guidance and see what's going to happen.

Right now I have urgent other work to do, but I will try as soon as
possible.

About the greatness of Octave: what I've read about it indicates the same
but I have to get it to work a) soon and b) reliably.
Yesterday, I have contacted Math Works about a MatLab license and they
told me that the cheapest solution I am entitled to costs about 2000 Euros.

This month I will earn not even that much (and there are other more
important things to pay [rent for one]), so obtaining this license
is out of question. That's why Octave is my only chance or I will lose
this contract work.

Best regards,
Georg Huber


Dear Thorsten,

you are a very patient person and your help is appreciated very much!
(I do have some special knowledge as well, so if you need help I will give
my very best. Just contact me via my E-Mail address.)

I will try what you wrote in your post as soon as the urgent work is done
(I hope by Friday afternoon).

No, I'm using Windows 7 Professional 64 bit. The XP-like look is intentional
because all this Aero stuff only slows down my machine.

I will also read the Wikipedia article you suggested.

Best regards,
Georg Huber


To everybody reading this:

What's the phase shift of the magnetic flux density (or inductance) B
between the transmitting coil and the receiving coil with two resonantly
coupled LC circuits as they are used in the newly arrived technique for
wireless power transfer called "WiTricity" by MIT?
(MIT uses no lumped capacitors but the inductance of the coils themselves.)

I have the suspicion it has to be PI/2 or rather 3*PI/2 for I think this
phase shift is enforced by Lenz's law. But I have never found anything
relating to that in the literature. Does anybody know?

(I hope I didn't break any rules by asking this here. If so, tell me and
it won't happen again.)

Best regards,
Georg Huber

GeorgHuber
Posts: 16
Joined: Fri 16 Mar 2012, 18:06

Re: openEMS & Octave

Post by GeorgHuber » Thu 22 Mar 2012, 18:20

Re: To everybody reading this: phase shift.

I think I found a suitable reference:

page 30, figure 9 in:
WIRELESS POWER TRANSFER – PRINCIPLES AND ENGINEERING EXPLORATIONS
Edited by Ki Young Kim
(http://www.intechopen.com/source/finals ... ations.zip

Here the energy of two resonant(ly?) coupled coil circuits is shown. The energy
flows back and forth between the coils with decaying amplitude because of the
losses.
The energy is proportional to B^2. This implies that the phase shift between the
two coil energies (PI) must be halved to arrive at the phase shift for B.
(Because in terms of energy the state B and -B in each coil can't be distinguished.)
If nobody differs, this reference is good enough for me.

What do you think about that?

Best regards,
Georg Huber

thorsten
Posts: 1425
Joined: Mon 27 Jun 2011, 12:26

Re: openEMS & Octave

Post by thorsten » Thu 22 Mar 2012, 20:54

It's okay to get a little bit off-topic, but since I can't say much to this wireless power transfer I can also get right back on topic :D
But it's also okay to create a new topic (maybe in "Usage") talking about specific problems and the their openEMS scripts.

Maybe I should talk a little about Matlab/Octave in general....

Matlab is kind of a programming/scripting language and the Matlab or Octave Command Line can interpret specific commands.
For example enter the following code in the Octave cmd (command line)

Code: Select all

x = 1:10;
y = x.^2;
plot(x,y);
So what are the .m-files for. Well if you want to calculate a long and complex problem you don't want to write all this stuff over and over into the command line... you put it all in a m-file: e.g. test.m.
Try it! Put the code above into a test.m file just in "D:\" maybe.

Then you do in the Octave cmd:

Code: Select all

pwd
cd D:\
test
This should give you an identical result. What does it do?
Line 1: Just showing you in which directory you are currently working (print working directory)
Line 2: change the current working directory to be D:\ where you test.m is located (change directory)
Line 3: execute script (Octave is looking for a file with ending .m --> test.m)

By default Octave is searching for a file in the current directory or all its known search paths (we need this for openEMS --> remember the addpath or SetPath in GUIOctave) or for a build-in function (in this order)

Now try this in the Octave cmd:

Code: Select all

addpath('D:\openEMS\matlab');
cd D:\openEMS\matlab\Tutorials
Simple_Patch_Antenna
What is it doing:
Line 1: adding the path D:\openEMS\matlab to the Octave search paths, so that Octave can find all the necessary openEMS specific functions and so on
Line 2: change the current working dir to be the openEMS Tutorial folder
Line 3: execute the Simple Patch Antenna tutorial example... Octave may ask you to delete the old result and than AppCSXCAD should open and if you close it, openEMS starts simulating...

(If you get an error that "h5reatatt_octave" was not found, execute "setup" and try again)

All this should work for you and completely without GUIOctave or what ever...

Of course if you want to modify the simulation script "D:\openEMS\matlab\Tutorials\Simple_Patch_Antenna.m" you need some (Text-)Editor.
You could e.g. use Notepad++ for it (http://notepad-plus-plus.org/). You should use one thats supports Syntax highlighting!

Or you use GUIOctave for that...
GUIOctave basically is just the Octave Command Line combined with an specialised Editor...
If you load a m.file e.g. "D:\openEMS\matlab\Tutorials\Simple_Patch_Antenna.m" into GUIOctave's Editor and hit "Run" it basically is doing two things for you automatically:

Code: Select all

cd D:\openEMS\matlab\Tutorials
Simple_Patch_Antenna
It changes the curr. work. dir and executes the script...

Advantages of GUIOctave vs. just plain Octave cmd + Notepad++:
  • If you get erros or warnings in you script, you can jump directly to that line by clicking on the warning...
  • If you put your curser on a function and press F1 you get a help info for that function (e.g. How to use it). When I just tried in my GUIOctave nothing happend, I don't now why.) This is very usefull (if it works, in Matlab I never had problems here)
  • You can execute just parts of a script... CRTL+ENTER executes lines enclosed by %%
  • some more I'm forgetting right now...
So you can do it either way is working for you...

I hope that clarifies some things and may help you...

But to be honest, Matlab/Octave is a complex and very powerful programming language and as a newbie to it (as you stated to be) this is no easy task and will take quite some time to learn. As it is difficult to learn any new language.
On top of that you have the powerful Matlab interface to a complex numerical method used by openEMS.
So this is what lies ahead of you:
  • Get to know and learn the Matlab/Octave programming language
  • Get to know and how to use the Matlab-Interface of openEMS
  • Understand the numerical method (FDTD) of openEMS and how to use it for you task...
To master one of this three is a lot of work... doing all three... well I wish you best of luck... :)

But on the other hand... all other numerical Software Packages would require a similarly difficult task...
Only instead of Matlab you would need to learn how to use their (limited) graphical user interface.

regards
Thorsten

GeorgHuber
Posts: 16
Joined: Fri 16 Mar 2012, 18:06

Re: openEMS & Octave

Post by GeorgHuber » Thu 29 Mar 2012, 11:12

Dear Thorsten,

having almost finished my other tasks, I'm back at
openEMS and GUI Octave.

I tried to run the file "Simple_Patch_Antenna.m".
It opened nicely in the GUI Octave Editor but
pushing the green triangular Run button threw
some error messages in the GUI Octave window:

>> Simple_Patch_Antenna
error: `physical_constants' undefined near line 18 column 1
error: called from:
error:
E:\PROGRA~1\MATHEM~1\openEMS\matlab\TUTORI~1\Simple_Patch_Antenna.m at line 18, column 1
>>

To tell the truth I'm getting rather frustrated. But I will try a complete
new install and see what's going to happen then.

Either you are all mentally some steps above me or there is a piece of
information that is somewhere implied and has simply been overlooked
by me.

Best regards,
Georg Huber

GeorgHuber
Posts: 16
Joined: Fri 16 Mar 2012, 18:06

Re: openEMS & Octave

Post by GeorgHuber » Thu 29 Mar 2012, 12:21

Dear Thorsten,

now I've just finished the complete reinstall of
Octave and GUI Octave.

(The previous installs were uninstalled by the
built-in uninstallers of the respective programs.)

I accepted all default settings.

The only difference is that I added the path "G:\openEMS\matlab"
instead of "D:\openEMS\matlab". This was necessary because on
my system the letter "D" is assigned to the DVD drive.

On the first start of GUI Octave there was a connection error 2
message, which I could get rid of by setting the path to Octave.

With next start of GUI Octave I tried again to open the file
"Simple_Patch_Antenna.m".

And again, this is the result in the GUI Octave window:

>> Simple_Patch_Antenna
error: `physical_constants' undefined near line 18 column 1
error: called from:
error:
G:\openEMS\matlab\TUTORI~1\Simple_Patch_Antenna.m at line 18, column 1
>>

It is maddening. The worst part is: even if I forked over 2000 Euros
to get a Matlab license I'm not sure that the same problem won't occur.
So I feel rather helpless and have to come to a decision:

1) Either hoping that there is a realistic chance to get openEMS running with Octave
and GUI Octave or
2) I invest some time and - grudgingly - some money (but 2000 Euros is way
to much, this I won't do for sure) to find an alternative.

For the time being I'm still clinging to decision 1. But if this frustration keeps
going on, I will have to switch to decision 2.

OK, so what shall I try relating to openEMS and (GUI) Octave in your opinion?

Best regards,
Georg Huber

GeorgHuber
Posts: 16
Joined: Fri 16 Mar 2012, 18:06

Re: openEMS & Octave

Post by GeorgHuber » Thu 29 Mar 2012, 13:04

Dear Thorsten,

here's the result of the next trial run of the
openEMS-Octave-GUI-Octave monster.

First, I restarted my computer.
Then I opened GUI Octave.

In the window titled "Octave Editor" I opened
"Simple_Patch_Antenna.m" and clicked on the
triangular "Run" button.

At first there was some activity noticeable:
The harddisk was accessed and the fan of the
computer got livelier. But the window titled
"GUI Octave" became unresponsive. Trying to
enter "1+1" after the prompt ">>" failed.

Checking the CPU load revealed that the computer
is idling (1% load). Therefore I conclude:
At least the window "GUI Octave" froze and something
has crashed without throwing an error code.

The funny thing is, that the simple command-line
(DOS style) window of Octave works:
It accepts "1+1" and hands back "2" upon Enter.

So Octave itself is working. What gave?

And most importantly: What might be the cause of
this behavior? How can it be remedied? Why does this
happen only to me (seeing no one else in this forum
with the same problem ...)?

As an afterthought:
Could this be a Win-7-64bit-issue?
Has anyone out there running
openEMS-Octave-GUI-Octave on a
Windows 7 64 bit Professional OS?

What are you using as OS, dear Thorsten?

Best regards,
Georg Huber

GeorgHuber
Posts: 16
Joined: Fri 16 Mar 2012, 18:06

Re: openEMS & Octave

Post by GeorgHuber » Thu 29 Mar 2012, 14:37

Dear Thorsten,

now some good news - at least for me:

I got openEMS-Octave-GUI-Octave running!

The bad thing about that good news is, that I can't write down
what exactly I have done.

I will try to to put down what I know I did:

1) I uninstalled GUI Octave (version: 1.3.0)
2) I looked for a newer version and found 1.5.4
3) I installed GUI Octave (version: 1.5.4)
4) I ran GUI Octave (version: 1.5.4)
5) I got a nicer GUI. The Editor / Debugger is now part of the window
titled "GUI Octave".
6) But alas: the same problem with the freezing interface.
7) Frustration, desperation: I clicked many times the button with the blue
plug-and-socket cable icon an low and behold the "Simple_Patch_Antenna"
script started working and the AppCSXCAD window opened.
This " I clicked many times the button ..." is the part of which I can't
remember how many times I clicked on that button. It also can be just
a lucky coincidence.

Now I'm going to uninstall everything again and try anew. If it will work again
I strongly suspect that the version 1.5.4 of GUI Octave is a must.

Best regards,
Georg Huber

GeorgHuber
Posts: 16
Joined: Fri 16 Mar 2012, 18:06

[SOLVED] openEMS & Octave & GUI Octave

Post by GeorgHuber » Thu 29 Mar 2012, 16:38

To all those who are in deep desperation with installing openEMS/Octave/GUIOctave,

read this and rejoice:

(As posted above, I intentionally erased a working installation of the Trinity and set about
to redo it and simultaneously write down what happens and what needs to be done.)

I unzipped openEMS to the following path:
I:\Installationsprogramme\Mathematik_Simulationen\openEMS

I installed GNU Octave under:
"E:\Programme\Mathematik_Simulation\Octave\3.2.4_gcc-4.4.0"

And then I made GUI Octave settle down at:
"E:\Programme\Mathematik_Simulation\GUIOctave\"
Make sure you have the latest version of GUI Octave, right now it seems to be 1.5.4.

GUI Octave enforces restart to complete its installation.

After restart of computer and opening "GUI Octave",
the following message shows in the upper textbox of "GUI OCtave" version 1.5.4:

"Error message: Redirect console error: 2"

OK. The reason may be the path in the inputbox in the upper right corner
saying "C:\Program Files (x86)\GUIOctave\Work".

Clicking on the browse button next to it I changed that path according to the
path I used for installing GUI Octave:
"E:\Programme\Mathematik_Simulation\GUIOctave\Work"

This didn't help. So I tried
File -> Options -> (left panel) Octave (right side) "GNU Octave - GNU Octave Executable Files Directory"
and entered there the path as per my install:
"E:\Programme\Mathematik_Simulation\Octave\3.2.4_gcc-4.4.0\bin"

Then I closed the program "GUI Octave" and started it again. A lot of text
appeared in the upper textbox. It starts with ">> >> .nargin." and ends with "dbcont".

As a kind of ever present header, this appears:

GNU Octave, version 3.2.4
Copyright (C) 2009 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.

Octave was configured for "i686-pc-mingw32".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Report bugs to <bug@octave.org> (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful report).

For information about changes from previous versions, type `news'.


Whether all that is important, I don't know. I put it down just for the record, so here's the complete list:

>> >> .nargin.
EDITOR
EXEC_PATH
I
IMAGE_PATH
Inf
J
NA
NaN
OCTAVE_HOME
OCTAVE_VERSION
O_APPEND
O_CREAT
O_EXCL
O_RDONLY
O_RDWR
O_TRUNC
O_WRONLY
PAGER
PAGER_FLAGS
PS1
PS2
PS4
P_tmpdir
SEEK_CUR
SEEK_END
SEEK_SET
SIG
S_ISBLK
S_ISCHR
S_ISDIR
S_ISFIFO
S_ISLNK
S_ISREG
S_ISSOCK
WCONTINUE
WCOREDUMP
WEXITSTATUS
WIFCONTINUED
WIFEXITED
WIFSIGNALED
WIFSTOPPED
WNOHANG
WSTOPSIG
WTERMSIG
WUNTRACED
__accumarray_sum__
__actual_axis_position__
__add_datasource__
__additional_help_message__
__all_opts__
__area__
__axes_limits__
__axis_label__
__bar__
__bars__
__builtins__
__clabel__
__contour__
__contourc__
__convn__
__current_scope__
__default_plot_options__
__delaunayn__
__display_tokens__
__dogleg__
__dsearchn__
__dump_symtab_info__
__end__
__errcomm__
__error_text__
__errplot__
__extractpath__
__ezplot__
__fdjac__
__finish__
__fltk_maxtime__
__fltk_redraw__
__get__
__glpk__
__gnuplot_get_var__
__gnuplot_ginput__
__gnuplot_has_feature__
__gnuplot_open_stream__
__gnuplot_version__
__go_axes__
__go_axes_init__
__go_close_all__
__go_delete__
__go_draw_axes__
__go_draw_figure__
__go_execute_callback__
__go_figure__
__go_figure_handles__
__go_handles__
__go_hggroup__
__go_image__
__go_line__
__go_patch__
__go_surface__
__go_text__
__gud_mode__
__img__
__img_via_file__
__init_fltk__
__interp_cube__
__isa_parent__
__isequal__
__keywords__
__lexer_debug_flag__
__lin_interpn__
__line__
__list_functions__
__magick_finfo__
__magick_read__
__magick_write__
__makeinfo__
__marching_cube__
__next_line_color__
__operators__
__parent_classes__
__parser_debug_flag__
__patch__
__pathorig__
__pchip_deriv__
__plr1__
__plr2__
__plt1__
__plt2__
__plt2mm__
__plt2mv__
__plt2ss__
__plt2sv__
__plt2vm__
__plt2vs__
__plt2vv__
__plt__
__plt_get_axis_arg__
__pltopt1__
__pltopt__
__qp__
__quantile__
__quiver__
__remove_fltk__
__request_drawnow__
__scatter__
__sort_rows_idx__
__splinen__
__stem__
__strip_html_tags__
__token_count__
__version_info__
__voronoi__
__which__
__xzip__
abs
accumarray
acos
acosd
acosh
acot
acotd
acoth
acsc
acscd
acsch
add_input_event_hook
addlistener
addpath
addproperty
addtodate
airy
all
allchild
amd
ancestor
and
angle
anova
ans
any
append
arch_fit
arch_rnd
arch_test
area
arg
argnames
argv
arma_rnd
arrayfun
asctime
asec
asecd
asech
asin
asind
asinh
assert
assignin
atan
atan2
atand
atanh
atexit
autocor
autocov
autoload
autoreg_matrix
autumn
available_backends
axes
axis
backend
balance
bar
barh
bartlett
bartlett_test
base2dec
beep
beep_on_error
bessel
besselh
besseli
besselj
besselk
bessely
beta
beta_cdf
beta_inv
beta_pdf
beta_rnd
betacdf
betai
betainc
betainv
betaln
betapdf
betarnd
bicgstab
bicubic
bin2dec
bincoeff
binocdf
binoinv
binomial_cdf
binomial_inv
binomial_pdf
binomial_rnd
binopdf
binornd
bitand
bitcmp
bitget
bitmax
bitor
bitset
bitshift
bitxor
blackman
blanks
blkdiag
bone
box
break
brighten
bsxfun
bug_report
builtin
bunzip2
bzip2
calendar
canonicalize_file_name
cart2pol
cart2sph
case
cast
cat
catch
cauchy_cdf
cauchy_inv
cauchy_pdf
cauchy_rnd
caxis
ccolamd
cd
ceil
cell
cell2mat
cell2struct
celldisp
cellfun
cellidx
cellslices
cellstr
center
cgs
char
chdir
chi2cdf
chi2inv
chi2pdf
chi2rnd
chisquare_cdf
chisquare_inv
chisquare_pdf
chisquare_rnd
chisquare_test_homogeneity
chisquare_test_independence
chol
chol2inv
choldelete
cholinsert
cholinv
cholshift
cholupdate
circshift
cla
clabel
class
clc
clear
clearplot
clf
clg
clock
cloglog
close
closereq
colamd
colloc
colon
colorbar
colormap
colperm
columns
com2str
comet
comma
command_line_path
common_size
commutation_matrix
compan
compare_versions
compass
complement
completion_append_char
completion_matches
complex
computer
cond
condest
confirm_recursive_rmdir
conj
continue
contour
contour3
contourc
contourf
contrast
conv
conv2
convhull
convhulln
convn
cool
copper
copyfile
cor
cor_test
corrcoef
cos
cosd
cosh
cot
cotd
coth
cov
cplxpair
cputime
crash_dumps_octave_core
create_set
cross
csc
cscd
csch
cstrcat
csvread
csvwrite
csymamd
ctime
ctranspose
cummax
cummin
cumprod
cumsum
cumtrapz
cut
cylinder
daspk
daspk_options
dasrt
dasrt_options
dassl
dassl_options
date
datenum
datestr
datetick
datevec
dbclear
dbcont


That's at least a sign of goodwill, so I pressed on.
Next I clicked along the following trail starting at the menu bar of GUI Octave:
File -> Set Paths... -> (button) "Add with Subfolders"
and enter the path suggested in
"http://www.openems.de/index.php/OpenEMS#Installation" i.e. "addpath('D:/openEMS/matlab');"
but of course differently: "I:\Installationsprogramme\Mathematik_Simulationen\openEMS\matlab"

It is to all appearances just necessary to steer to the path openEMS was
extracted in and then going to the "matlab" part as indicated above.
Then a message replaces the list, saying in essence that GUI Octave adds all
the paths found within the "matlab"-path. Then I closed GUI Octave and reopened it.

And now some small success:

">> >> 1+1
ans = 2
>>
"

But there is no menu bar in the "Editor / Debugger" textbox (lower part of the
display). The uneasy feeling starts again. Frustration is looming.

But here's the trick: Close "GUI Octave" and reopen it again:
Everything is there where it is supposed to (at least I hope so, but it looks
neat and tidy: the "Editor / Debugger" is back and this time with a menu bar!

OK. Now for the big one:
(Menu bar of the "Editor / Debugger") File -> Open... -> (put in YOUR path to
the trial files, mine is:)
"I:\Installationsprogramme\Mathematik_Simulation\openEMS\matlab\Tutorials\Simple_Patch_Antenna.m"

Hit Open (or Öffnen) or what your windows language pack suggests.

In the "Editor / Debugger" textbox the content of the trial file
"Simple_Patch_Antenna.m" is shown. Tears are welling up in my eyes. Birds are singing louder.
I press the ominous green triangle button (tooltip text: "Run / Debug / Continue" and the
"AppCSXCAD" window appears. I can't help sobbing.

Days of trial and error are over! I'm free at last to do what I wanted to do in the first place:
simulate the B-field of a WiTricity-like setup. Now I hope openEMS is up to the task!

I hope this install guide is of any help for other tormented souls out there.
I wrote this down while doing the install.
Oh, yes: All those installs, trials and errors and a lot of search on the web took the better
part of week. This install done by this guide will take you (depending on the speed of your
Internet connection and of your computer) half an hour at the most.

When there are results of my inadequate tinkering with things far beyond my horizon, I will try
to post the way I got there.

Best regards,
Georg Huber

And special thanks to Thorsten who showed me that there must be a way leading to a
working installation of the openEMS/Octave/GUIOctave Trinity.

Post Reply