-
Notifications
You must be signed in to change notification settings - Fork 123
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
Improve mapdl.convert_script
#2157
Comments
Thanks @clatapie for this initiative and prioritize this activity. The improvement to the mapdl.convert script is essential. As a user, I am expecting this script should convert MAPDL commands in to PyMAPDL equivalent commands (those are already exposed and documented) apart from above improvements as highlighted. Please do let me know if any help needed. Thanks ! |
This issue is linked with #1955. |
This is a very good initiative. Let discuss some of the points:
There is this flag in the
PyMAPDL will print all the
If we implement that change, nothing will be writen to the file.
I fully agree with this approach. It is going to be a challenge to efficiently replace the var in the rest of the file though.
For the same reasons as the
to: results = f"""
------------------- VM13 RESULTS COMPARISON ---------------------
RESULT | TARGET | Mechanical APDL | RATIO
Stress, Y (psi) {Target_values[0]:.5f} {stress_y:.5f} {abs(stress_y/Target_values[0]):.5f}
Stress, Z (psi) {Target_values[1]:.5f} {stress_z:.5f} {abs(stress_z/Target_values[1]):.5f}
-----------------------------------------------------------------
"""
print(results)
with open("vm13.vrt", "w") as fid:
fid.write(results)
# this file is written in the python working directory (`os.getcwd()` output).
# If you need it in the remote MAPDL instance, you can upload it to the MAPDL
# working directory using:
mapdl.upload("vm13.vrt") But as it can be seen, not all the scripts might require that conversion. Furthermore, it can be extremely manual (the
I'm fine with that. But what is a section in an MAPDL script? There is not such concept in an APDL script. Pinging @pmaroneh @mcMunich @mikerife for optional feedback (I know you are busy) |
Thank you for this complete feedback @germa89. I think that if tables are in a MAPDL script, it will always be implemented that way. So in my opinion, I don't think it's specific to VM files. We could add an option for making this change or not (something like I was thinking that the comment for each sections could automatically be added before a Also, we could add an option to check the result obtained by the conversion of the APDL script. It could be a basic run of the file and returning a warning if the script needs further attention or modifications. |
I think we should start from end (python user) to beginning (MAPDL code). What is the natural way a python user will use those tables? How can we convert that MAPDL code so it prints/shows what that user is expecting in the way he/she is expecting?
I really like this! |
I agree! I usually print a table of results with the following Python code: import pandas as pd
table = [[4, 5, 5, 70], [4, 5, 5, 70]]
columns = ['a', 'b', 'c', 'd']
index=['row_1', 'row_2']
df = pd.DataFrame(table, columns = columns, index=index)
print(df) It then renders as follow: a b c d
row_1 4 5 5 70
row_2 4 5 5 70 Another option could be to use the tabulate library. |
Unless Tabulate is not a bad option either. Using format directly is another option. Up to you. But using pandas only for this is a bit of an overkill 😄 |
Thank you for your feedback @RobPasMue. You're right about the dependency issue, I will avoid to use pendas then. |
@clatapie and all, We need to expose all supported PyMAPDL equivalent functions via convert_script: mapdl.get("RF_XT01", "FSUM", "", "ITEM", "FX")---> can we assign it to some variable like below Will append this list. Thanks ! |
The converted has been improved quite a lot in #2433 Now it renders: """Script generated by ansys-mapdl-core version 0.68.dev0"""
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(loglevel="WARNING", print_com=True, check_parameter_names=False)
mapdl.run("THICK = 1")
mapdl.sectype(1, "SHELL")
mapdl.secdata("THICK", 1)
mapdl.finish()
mapdl.run("SFCONTROL,2,,1,1,,1,,,2")
mapdl.exit() Regarding var1 = mapdl.get_value("RF_XT01", "FSUM", "", "ITEM", "FX") Same with |
After long time with not much work in the specific issues raised in this PR, I have to comment:
As metioned, this was already in place with ``mapdl.print_com = True```.
Difficult to do this one, because we will have to do regex to search the file for where this var is used. And there could be edge cases. I don't think we have the man power for this.
For the VMs might be a good reason. For the rests of the cases, I dont think we should replace
We cannot really tell what is a section in an APDL script. Hence I do not recommend to do this. Hence I'm closing this issue. Unless new info, request or work happens. |
After some discussions with @vnamdeo, @germa89 and @RobPasMue, improving the function
mapdl.convert_script
seems essential to facilitate the VM file conversion process.This can be done with the following changes :
*COM
should in fact return aprint()
or a Python comment#
*GET
should be converted intovar = mapdl.get("VAR")
. The python variablevar
needs to be the one used in the rest of the file*VWRITE
should be converted intoprint()
involvingpandas
tables.##################
and~~~~~~~~~~~~~~~~
The text was updated successfully, but these errors were encountered: