ansys / pymapdl

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

Selecting License? #462

Closed natter1 closed 2 years ago

natter1 commented 3 years ago

We have different ANSYS licenses available in our group. For most simulations we use ANSYS Academic Teaching, which is selected via ANSYS Mechanical Product Launcher. Today I blocked the Academic Research License because(?) a crashed script didn't finish the ANSYS task a few days ago (at least thats my best guess). The issue here, I didn't even want to use the Academic Research License for my PyMAPDL-Script in the first place, and I have no idea why it was used. How does PyMAPDL decide which license is used when starting MAPDL (if not set via additional_switches)? Does it also take the setting from the ANSYS Mechanical Product Launcher? Or might it depend on what the script is doing? I played a little bit with pooling last week - maybe this needed the Academic Reasearch License? How to "force" to use of Academic Teaching License inside the script? Is there a list of possible additional_switches values?

natter1 commented 3 years ago

Part of the question has already answers in the docu. Some of the additional_switches can be found as note here. For the licence switch, its possible to use the APDL launcher (tools->view launcher log file). For academic teaching its aa_t_a. So the only open question is, how a license is selected, if additional_switches is not used.

akaszynski commented 3 years ago

There really should be docs regarding this. When I find time to focus on a solid docs PR for MAPDL, I'll patch this up. Right now, working on getting enough inertia on pyvista=0.31.0. You were right about it taking a while :).

akaszynski commented 3 years ago

Part of the question has already answers in the docu. Some of the additional_switches can be found as note here. For the licence switch, its possible to use the APDL launcher (tools->view launcher log file). For academic teaching its aa_t_a. So the only open question is, how a license is selected, if additional_switches is not used.

Docs and APIs aren't great for this. Ideally, switches would be parsed when submitted and the PyMAPDL API would have to maintain a list of available switches (not too bad). Additional license switches might be a pain to add to this list as well.

An additional option would be to have kwargs for the available options for launching MAPDL. It would lead to a long docstring and signature, but it's better than guessing what switches are available. Would that be an improvement on the api? Something like:

def launch_mapdl(existing_args, ... 
                 academic_research_license=False,
                 academic_teachers_license=False)

Another option, would be to create an "additional options" class that can be input instead (or as an option for) the additional_switches argument. Something like:

switches = MapdlSwitches()
switches.academic_research_license = True

Such classes would let us perform validation up-front and interactively. For example:

>>> switches = MapdlSwitches()
>>> switches.academic_research_license = True
>>> switches.academic_teachers_license = True
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-27-86b8e6e3a46d> in <module>
----> 1 raise ValueError('Can only select one academic license type')

ValueError: Can only select one academic license type
natter1 commented 3 years ago

Another option, would be to create an "additional options" class that can be input instead (or as an option for) the additional_switches argument. Something like:

That would be my personal preference (also for documentation). The best case would be, if such an object could handle priorities (same as in the license preferences tool, where you can order the available licenses). But that might make the object too complicated.

ValueError: Can only select one academic license type

Hm, wouldn't it be better to use an ENUM for mutal exclusive options? Or it should be handleed via property-setter (maybe with a warning, if setting one license to True would remove another license).

As a fall-back a parameter to set the switches e.g. as a string might help with new switches, that are not implemented in pymapdl jet.

germa89 commented 2 years ago

It seems that teaching and academic licenses are legacy and they probably won't last much. There are equivalent mechanical licenses that we could check against. Let's say 'ansys', 'meba', 'mech_1' and 'mech_2'.

I'm going to implement an optional keyword argument which you can use to input the desired license name. If not using one of the four above, it will raise a warning but still you could go ahead.

akaszynski commented 2 years ago

One note here, it seems that we're unable to set the academic license directly with 2021R1 and newer. For details, see: https://github.com/pyansys/pymapdl/issues/658#issuecomment-943975961