Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to work with GeneratorSE 2.0 examples #10

Open
herminiomiguel opened this issue Nov 17, 2023 · 24 comments
Open

How to work with GeneratorSE 2.0 examples #10

herminiomiguel opened this issue Nov 17, 2023 · 24 comments

Comments

@herminiomiguel
Copy link

I received a PC with WISDEM working correctly (both GUI and examples). Thus, I have successfully installed the GeneratorSE 2.0 in the same WISDEM environment, but the examples do not work, as observed in the following issue. Could you please guide me on how to resolve this problem? Thank you!

image

@ptrbortolotti
Copy link
Contributor

the error seems to come from openmdao. please make sure that openmdao is installed correctly. however I will add that the libraries, especially pyfemm, of GeneratorSE 2.0 have always been tricky to compile correctly. I would recommend first trying a clean environment with only generatorSE without WISDEM and its dependencies

@herminiomiguel
Copy link
Author

Hello Bortolotti. Thank you for the tips! I ran some examples from the Openmdao homepage (https://openmdao.org/newdocs/versions/latest/examples/examples.html) such as the list mentioned below. Besides, the same procedure for the pyFemm it was done (https://www.femm.info/wiki/pyFEMM). Both carried out sucessfully and, apparently, they seem to work without any problems.

Openndao examples:
Simple Optimization; Wind Turbine Actuator Disc; Converging an Implicit Model; Nonlinear circuit analysis; and Simple Optimization using Simultaneous Derivatives

pyFemm examples:
Coilgun, Demo2, stripsm, htutor, ACElec2, and Phase3

After that, I created a new environment with only GenratorSE (carrying out the same tests for Openmdao and pyFemm before) and the same message error appears for me:

image

@gbarter
Copy link
Member

gbarter commented Nov 27, 2023

This was indeed an error in the nlopt_driver.py code as it used a call that was modified in the upstream OpenMDAO library but not kept up to date here. I just pushed a fix to the dev branch in this GeneratorSE repository. The steps to use it would be:

git checkout dev
git pull

And then give the example another try.

@herminiomiguel
Copy link
Author

Hello Barter,

After updating with the fix above, a new error message is shown now (see below). The generatorSE does not recognize the NloptDriver as a script installed.

image

Here is the nlopt_driver.py location

image

Thank you in advance,

@herminiomiguel
Copy link
Author

I'm come back! After reading carefully the code from nplot_driver.py, I identified the absence of the package NLopt in my env. Therefore, problem fixed, but the examples were running partially ok. PMSG works well; IPM reports about "No module named 'sympy', while LTS about 'float division by zero'.

image

image

@gbarter
Copy link
Member

gbarter commented Dec 19, 2023

Looks like you have to conda install sympy or pip install sympy and try again.

@herminiomiguel
Copy link
Author

Indeed, I was commiting a mistake when searching for the packages, but I identified the (simple) problem two days ago... I had "sImpy" installed instead of "sYmpy" (ok, reading fast they look identical) and now the IPM script is running very well.

But the LTS still has the same problem, i.e. "float division by zero".

@gbarter
Copy link
Member

gbarter commented Dec 21, 2023

It looks like we have some staged improvements still in the dev branch. If you did git checkout dev and tried the LTS example again, does that work?

@herminiomiguel
Copy link
Author

Tip carried out, but without success. Here is the full error message (the previous picture does not have the second part):

image

image

@gbarter
Copy link
Member

gbarter commented Dec 21, 2023

Hmm. I just tried a fresh conda environment and fresh sync/install with the repository. On the dev branch, everything works fine for me. If you do git status do you see any files changed? If might also help if you did a conda list and pasted the results here.

@herminiomiguel
Copy link
Author

It is mentioned about untracked files (indeed, the LTS files):
image

And here is the packages list:
image

image

@gbarter
Copy link
Member

gbarter commented Dec 21, 2023

And you can confirm that you have FEMM installed in the standard location?

@herminiomiguel
Copy link
Author

It is installed in the path suggested by the installer, at the hard disk root ( C:\ ). Is this one the standard location?

@gbarter
Copy link
Member

gbarter commented Dec 22, 2023

In your folder, GeneratorSE\examples\lts, can you make sure that you have deleted all other folders and csv-files? There is a "restart" capability and if some prior runs didn't succeed, they can corrupt future runs. This restart capability can be turned off, but I think is on by default.

@herminiomiguel
Copy link
Author

I gave up on the previous one and tried a new environment, however the same problem persists (i.e. PMSG and IPM fine, but LTS fails). Please, look at my LTS folder before/after running the script above. First, I tested deleting just the folders and then I also tried the "coil_design" files too, but nothing changes.

About the "restart capability", I assume it is "restart_flag" flag in the script run_lts.py, right? I swithed it to the false option, but the script still works wrong.
line 36: def optimize_magnetics_design(prob_in=None, output_dir=None, cleanup_flag=True, opt_flag=False, restart_flag=True, obj_str="cost", ratingMW=17)

image

image

@gbarter
Copy link
Member

gbarter commented Jan 5, 2024

I was stumped for a while, but may have just found the issue. I pushed an update to the run_LTS.py in the dev-branch. Can you do, git pull and then try again?

I know this has become frustrating for you, but I think you are the first non-NREL user of this new GeneratorSE code and I really appreciate your patience!

@herminiomiguel
Copy link
Author

Hello Garrett,

I tried testing the update using my previously installed system and another try with a fresh environment. Both cases show a new error message now. Instead of the traceback reporting the exception starting at the line 425 (get_eff_curve(f"outputs{k}-cost", "cost", k)), as shown in my previous comments, now it is related from line 433 (run_all(f"outputs{k}-{obj}", opt_flag, obj, k)) . I think the the error report are similar (or the same scope) because both they are running on the last condition in the script (if name == "main").

image

Thank you for your help. And trying to make this script work fine is not frustating but a good chalange!

@gbarter
Copy link
Member

gbarter commented Jan 27, 2024

Sorry for the long delay. I did come back to this and am perplexed how you can be experiencing the divide by zero error. Seems like something must not be installed or running correctly. Maybe we should schedule a direct meeting where we can share screens?

@herminiomiguel
Copy link
Author

Hello Garrett,

Yesterday I was out on external work from my office, thus I could not reply you, sorry.

But in the last week I tried to debug the LTS example and it is possible to see the critical variables h_s and h_sc always equal to zero. So, in the script "magnetics_design.py" I tried to force the variables for the lower value proposed in the "run_LTS.py" (0.03 m and 0.05 m, respectively). The trick initially works good, but both variables return to zero when the loop start again.

image

Related to the meeting, I think it woud be great, thank you in advance! In the current week I have free slots tomorrow afternoon (until 7:30 PM), and Thursday and Friday all day (from 8:30 AM). My current local time zone is GMT+1 (France).

Best regards,

@gbarter
Copy link
Member

gbarter commented Jan 31, 2024

Can you email me at the link on the home GeneratorSE README for NREL Author Team? I will then send you an invite for Thursday at 0800 for me, 1600 for you if that is okay.

@gbarter
Copy link
Member

gbarter commented Jan 31, 2024

Well, this is embarrassing. I was finally able to recreate your issue and fix it (on the dev branch). Do a git pull and let me know if it is fixed on your side. If so, we can cancel our meeting. I sincerely apologize for the delay in getting this resolved- it was totally on me.

@herminiomiguel
Copy link
Author

Hello Barter,

I decided to use a clean environment and the LTS script works fine. Thank you for all support and hard work.

Now I am trying to understand the output results, so I have the folowing doubts. For example., for all powers ratings, the terminal always gives the same results for the variables and I am not totally sure about them (I have never worked with SCG or FEM applied to electrical machines before):
N_c (armature turns/phase/pole) = 1 turns;
N_sc (field coil turns) = 2811.37208924 turns (the rounding does not seem to work);
B_coil_max = 1T;
l_s (stack length) = 1 m.

Besides, another possible issue is the fem file created. My first impression is that the field diameter seems to be slightly out of proportion, as seen in the 25MW design:
image

So, for the moment, above are my first (and superficial) analyses. And I hope to help for ensure more performance in the framework.

Best regards,

@gbarter
Copy link
Member

gbarter commented Feb 1, 2024

Phew- at least things are working. My apologies again for the long delay and hassle in resolving things.

In the outputs folder(s), you should find an Excel file that has a more neatly printed set of outputs. With the optimization flag set to False, indeed all of the designs have the same input. Look at the bottom of the run_LTS.py file and you will see how to turn on the optimization flag and run at certain power ratings.

If you want to recover or run the designs associated with the paper where the work was published, I can give you the appropriate restart-file.

As for a good interpretation of the results, I am not a electric machine expert, but I can forward any questions to have to our team here at NREL. The model is acknowledged to be lower fidelity, but the resulting designs did go through a good deal of scrutiny and sanity checks.

Do you still want to meet in a couple of hours?

@herminiomiguel
Copy link
Author

If it is possible for you, I would like to hold the meeting (shorter now) to try to clarify a few points about the Wisdem/GeneratorSE 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants