ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
428 stars 120 forks source link

When I refine the mesh, the model isn't solved. Any suggestions as to why? #225

Closed echatziz closed 3 years ago

echatziz commented 4 years ago

I am running some opto-thermal simulations. I am calculating the absorption separately, and applying it to my steady-state thermal model as a volume source with the BFE command.

I am meshing by defining the edge length with Esize. Until a certain limit the model is solved as expected, but when I go below it, the model isn't solved. Is there a time-out in calculations? Is there a reason for it?

For example, for edge length 0.025 that results in a mesh of 320,000 elements the model is solved. When the edge length is 0.02 that results in a mesh of 625,000 elements the model fails to be solved.

Thank you

akaszynski commented 4 years ago

Hello,

It's possible that the mesh quality falls below acceptable values, but if SHPP, ON, this probably isn't happening. Memory shouldn't be an issue either as the solve will just use a pagefile instead of RAM.

Could you please post the specific error you're getting here? If possible, can you upload the input file/script as well?

echatziz commented 4 years ago

I haven't used the SHPP, ON command, and I don't get any error messages either.

I have uploaded the script, and two input files. The "volume_data.txt" is for 10 pixels, the other "volume_data_1000000_8pixels" is for 8 pixels. If you want to test the 8 pixels file, you have to change the z_pixels variable in line 25 from 10 to 8.

opto-thermal-steady-state.zip

Thank you!

akaszynski commented 4 years ago

Awesome. I'll look at this today.

akaszynski commented 4 years ago

Ran this on Linux v150 and the solution completed, though I'm seeing different results:

z_pixels = 8

file001

z_pixels = 10

file000

It looks like the solution still solves in both cases though. Is this not occuring on your end?

echatziz commented 4 years ago

I don't know why the first result looks like that, the second picture is what I am usually getting. It may depend how the mesh is created, the element numbering etc.

For me, for z=10 pixels, the model isn't solved. I don't get any error messages, but the resulting picture is the mesh in the initial temperature, 22 degrees.

For these parameters, I am getting lower temperatures. In general, I tried to have all material properties in the same scale, mm, as you cannot explicitly define units

akaszynski commented 4 years ago

With z_pixels = 10 my model is solving with ANSYS v15 on Linux. You can get better plots using pyansys's binary result reader:

import pyansys
rth = pyansys.read_binary('file.rth')
rth.plot_nodal_solution(0)

pyansys_183

It's possible there's some problem with CORBA, which is ANSYS's interface for using MAPDL as a service on Windows. There's some known bugs with it and that feature will likely be replaced with one that works better over the next two releases.

Can you please set your log_level='INFO' and then post the output here as a file?

echatziz commented 4 years ago

Sure, I will upload the file. I haven't updated the library or the version of ansys I am using in a while. Perhaps these bugs were fixed on later versions.

It's Saturday evening, and I don't have access to my office computer from home. I'll be in the office on Tuesday, Monday is a public holiday in Germany, and I'll upload it then.

Thank you.

akaszynski commented 4 years ago

No rush. I'll also try running this locally on Windows to see if I can duplicate the problem as well.

echatziz commented 4 years ago

I am attaching the loglevel = 'INFO'

By the way, the first pic for 8 pixels looks like that because you didn't use the input file for 8 pixels, I attached two, but that doesn't matter for the current issue I am having.

loglevel_info_8pixels.txt loglevel_info_10pixels.txt

[edit] I attached the loglevel file for both cases that model is solved and isn't solved. I get pics like these file014 file015

Thank you again

akaszynski commented 4 years ago

According to the logs, both solutions solved correctly. Are you able to access the solution results using the result reader as I had done?

import pyansys
rth = pyansys.read_binary('file.rth')
rth.plot_nodal_solution(0)
echatziz commented 4 years ago

No, I could never use this plot_nodal_solution() function. I get the following error message:

Traceback (most recent call last):

  File "<ipython-input-5-d66a5fddebdb>", line 1, in <module>
    rth.plot_nodal_solution(0)

  File "C:\Users\E.Chatzizyrli\AppData\Local\Continuum\anaconda3\lib\site-packages\pyansys\rst.py", line 335, in plot_nodal_solution
    **kwargs)

  File "C:\Users\E.Chatzizyrli\AppData\Local\Continuum\anaconda3\lib\site-packages\pyansys\rst.py", line 1291, in _plot_point_scalars
    rng = kwargs.pop('rng', [scalars.min(), scalars.max()])

  File "C:\Users\E.Chatzizyrli\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\core\_methods.py", line 32, in _amin
    return umr_minimum(a, axis, None, out, keepdims, initial)

ValueError: zero-size array to reduction operation minimum which has no identity

And I always had that issue. The binary files are not created .rth properly. I had tried to retrieve the data, but couldn't do it

akaszynski commented 4 years ago

Ok. Going to try this out in windows with this version of ANSYS. Do you have access to a newer version of ANSYS or a different OS? I'm having the feeling that it might be a MAPDl issue.

echatziz commented 4 years ago

I can try to download the new version of Ansys, but in our institute we cannot use Linux, only windows

akaszynski commented 4 years ago

I'd try upgrading and seeing if the problem persists.

echatziz commented 4 years ago

I have updated the ANSYS version to 2020 R1, got the newest one. The problem persists. For 10 pixels, I get the mesh in the initial temperature as before. Now when I am trying to read the binary and plot, the program crashes, before it just wouldn't work

rth = pyansys.read_binary('file.rth')
rth.plot_nodal_solution(0)

The pyansys version I am using, pyansys.version is 0.39.3. May that be the problem?

akaszynski commented 4 years ago

Yes, you'll have to upgrade to the latest as they introduced sparse compression in the later versions of MAPDL. Run:

pip install pyansys --upgrade
echatziz commented 4 years ago

Ok, now I have upgraded both the library and ansys. But instead of the model being solved the Mechanical APDL 2020 R1 Output Window is prompted and the execution stops there. I never had this problem before. Namely, never before was the output window prompted like that. The version is pyansys.version = 0.40.2 Although I tried reading the binary output file from a previous simulation and that works fine. A few hints how to plot cross-sections, and customize the labels would be welcome. screenshot

akaszynski commented 4 years ago

Try downgrading to 0.40.1 for the moment. Looks like this is an issue with the corba interface on windows. Sorry this is such a hassle...

akaszynski commented 4 years ago

While working on this, I found a ton of issues with CORBA. I've cleaned it up and 0.41.0 captures most of the fixes. The API has changed a bit, so please see the documentation.

Once I get a spare moment I'll be able to debug why this script isn't working on 19.4 and 20.1.

echatziz commented 4 years ago

Ok, I upgraded to 0.41.0, and nothing works again. I changed pyansys.ANSYS() to pyansys.launch_mapdl(), but I see now that I have to use a lower case letter as the first letter in all the commands, before it was capital. I'll try it and see if it works.

ps. Upgrading and downgrading packages is kind of frustrating for me, because I can't do it on the company network and have to get external wifi each time, and then in order to test if it worked, I have to reconnect to the company network since we have a floating license for ANSYS.

echatziz commented 4 years ago

ansys = pyansys.launch_mapdl() never executes, no error, no nothing. The programm is stuck there. I guess it's the same problem as before, just that I don't actually see the mechanical apdl output window being prompted.

Ah, no. I get a message now that ANSYS was unable to start within 120 sec, the program timed out

Can you please tell me what changes in the new api apart from the initial letter and why it doesn't work at all for me? opto-thermal-steady-state.zip

echatziz commented 4 years ago

I downgraded to 0.40.1 and the initial problem persists, the model isn't "solved" for 10 pixels, but at least the model runs, I did have a panic attack with all the upgrading/downgrading, and I am sorry for the many messages

echatziz commented 4 years ago

Ah, and another issue that I have observed is that the mesh doesn't seem well defined. Now that I visualize it with

rth = pyansys.read_binary('file.rth')
rth.plot_nodal_solution(0)

result

Is there sth that can be done? I've turn the ansys.Run("SHPP,ON"), but it didn't make a difference, and with ansys.Run("SHPP, SUMM"), I don't get any warnings or errors. Although there is a gap in the mesh, so the elements may indeed be well formed

akaszynski commented 4 years ago

ansys = pyansys.launch_mapdl() never executes, no error, no nothing. The programm is stuck there. I guess it's the same problem as before, just that I don't actually see the mechanical apdl output window being prompted. Ah, no. I get a message now that ANSYS was unable to start within 120 sec, the program timed out

I absolutely understand your frustration. Getting this working is quite challenging as CORBA/AAS isn't well supported from ANSYS, and getting this to launch consistently is a real nightmare. ANSYS will be releasing a new interface that is an improvement, but at the moment we have to work with what we have.

I can't say why it's not launching on your end. It launches locally for 19.4 and 20.2 (pre-release). Can you please set loglevel="DEBUG" and see what output you get on 0.41.0? Debugging this will help many users. Also, if you wouldn't mind posting the ANSYS version(s) you're using when you try this out?

echatziz commented 4 years ago

Yeah, I downgraded to 0.40.1 as I said in one of my messages, and now my model works, although the initial problem persists. Can you help me with that?

I really don't want to upgrade again to 0.41.0, since you've changed your api, and I want to avoid dealing with that on top of everything else.

And could you please give some feedback as to why my mesh looks like in the pic above? Could you suggest sth to make it better?

I appreciate all the effort you're putting in this :)

akaszynski commented 4 years ago

Yeah, I downgraded to 0.40.1 as I said in one of my messages, and now my model works, although the initial problem persists. Can you help me with that?

Yes. Please let me know which version of ANSYS works with 0.40.1. I'd like the current version to work for future pyansys users.

I really don't want to upgrade again to 0.41.0, since you've changed your api, and I want to avoid dealing with that on top of everything else.

Completely agree with that. It's a tough balance between modernizing an interface and maintaining backwards compatiblity.

And could you please give some feedback as to why my mesh looks like in the pic above? Could you suggest sth to make it better?

The problem is likely occuring on pyvista or pyansys. Can you please run:

import scooby
scooby.Report(['pyvista', 'pyansys'])

and post the report here. I'll see what's causing the issue.

echatziz commented 4 years ago

Yes. Please let me know which version of ANSYS works with 0.40.1. I'd like the current version to work for future pyansys users.

I updated ANSYS to 2020 R1.

Just left the office, I am back there on Friday, so I'll upload the report then.

echatziz commented 4 years ago

Are there any updates on this bug for ANSYS 2020R1 and pyansys.version 0.40.1?

That's what I get after running ` scooby.Report(['pyvista', 'pyansys'])`
 --------------------------------------------------------------------------------
  Date: Thu Jun 18 18:00:20 2020 W. Europe Daylight Time

                OS : Windows
            CPU(s) : 32
           Machine : AMD64
      Architecture : 64bit
               RAM : 127.9 GB
       Environment : Jupyter

  Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]

           pyvista : 0.25.1
           pyansys : 0.40.1
             numpy : 1.18.1
             scipy : 1.4.1
           IPython : 7.13.0
        matplotlib : 3.1.3
            scooby : 0.5.5

  Intel(R) Math Kernel Library Version 2020.0.1 Product Build 20200208 for
  Intel(R) 64 architecture applications
--------------------------------------------------------------------------------
akaszynski commented 4 years ago

Sorry, been caught up with other projects. Not updates yet, but I'll try to run the batch today and debug it.

echatziz commented 4 years ago

Hi, I have updated the library version and using ANSYS 2020 R1. But this problem that I cannot refine the mesh persists. There is the issue of thermal stability we're discussing in another topic, but tests suggest I should refine the mesh regardless. You can see the latest version of my model below. Up until z = 8 pixels everything works, but for z = 10 pixels the model continues not to be solved opto-thermal-steady-state-new.zip

echatziz commented 3 years ago

This was resolved after updating pyansys

akaszynski commented 3 years ago

It only took a year for us to fix it! Thanks for following up on this issue.