question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Did you publish this tutorial ? I'm having hard time running it at current time it keep failing

See original GitHub issue

Sadly, MAPDL doesn’t directly support reading STEP files, but it turns out you can do it with gmsh!

Figure_1

I’m working on a tutorial right now, but the gist of it is:

import gmsh
import math
import os

gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)

gmsh.model.add("t20")

# Load a STEP file (using `importShapes' instead of `merge' allows to directly
# retrieve the tags of the highest dimensional imported entities):
# path = os.path.dirname(os.path.abspath(__file__))
filename = 'pf_coil_case_1.stp'
v = gmsh.model.occ.importShapes(filename)


# Get the bounding box of the volume:
gmsh.model.occ.synchronize()

# Specify a global mesh size and mesh the partitioned model:
gmsh.option.setNumber("Mesh.CharacteristicLengthMin", 10)
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 10)
gmsh.model.mesh.generate(3)
gmsh.write("from_gmsh.msh")

# Show the result:
# gmsh.fltk.run()

gmsh.finalize()

That gives you your gmsh file. You can then convert it to MAPDL with:

import pyvista as pv
import pyansys

filename = '/home/alex/.local/lib/python3.7/site-packages/gmsh-4.6.0-Linux64-sdk/share/doc/gmsh/tutorial/python/t20.msh'
mesh = pv.read_meshio(filename)
# mesh.plot()
mesh.points /= 1000
pyansys.save_as_archive('archive.cdb', mesh)

mapdl = pyansys.launch_mapdl(exec_file='/ansys_inc/v194/ansys/bin/ansys194',
                             override=True, additional_switches='-smp')
filename = '/home/alex/Downloads/two_step_files/archive.cdb'
mapdl.cdread('db', filename)

I’m going to have to clean it up for an example, but it’s quite promising. Once you have the mesh, you can go ahead and analyze it in MAPDL. According to mesh.bounds, it seems that the dimensions are in mm. You’ll have to scale it down and then copy it over to MAPDL with mesh.points /= 1000 prior to saving it.

I did a quick modal analysis because they make great gifs, but you’ll probably want to do a structural analysis.


# verify cells are valid
mapdl.prep7()
mapdl.shpp('SUMM')

# specify material properties
# using aprox values for AISI 5000 Series Steel
mapdl.units('SI')
mapdl.mp('EX', 1, 200E9)  # Elastic moduli in Pa (kg/(m*s**2))
mapdl.mp('DENS', 1, 7700)  # Density in kg/m3
mapdl.mp('NUXY', 1, 0.3)  # Poissons Ratio
mapdl.emodif('ALL', 'MAT', 1)

# Run an unconstrained modal analysis
mapdl.run('/SOLU')
mapdl.antype('MODAL')  # default NEW
mapdl.modopt('LANB', 20, 1)  # First 6 modes above 1 Hz
mapdl.solve()

result = mapdl.result

# result.plot(cpos='xy')
cpos = [(0.0, 0.3074999999873, 2),
        (0.0, 0.3074999999873, 0.5),
        (0.0, 1.0, 0.0)]


result.animate_nodal_displacement(4,
                                  cpos=cpos,
                                  show_edges=False,
                                  lighting=True,
                                  loop=True,
                                  add_text=False,
                                  nangles=30,
                                  movie_filename='tmp.gif')

tmp

_Originally posted by @akaszynski in https://github.com/pyansys/pymapdl/issues/234#issuecomment-649240031_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
akaszynskicommented, Sep 14, 2021

I’m closing this issue since I believe now it is all working fine. Feel free to re-open if you fill I missed something or open another one if you have any more issues.

This is great work, and I’d like to add it as a static example (not one we compile each time) to the docs. Create a new directory in doc/user_guide/extended-examples and add index.rst along with a new example file (you pick the name). Describe the example as you’ve done above, but just in markdown.

Reopening as another “TODO”. This shouldn’t be too bad since you’ve already done the hard work of writing the example.

1reaction
Ahmadbelbeisicommented, Sep 29, 2021

Thank you so much guys, this example is definitely a great addition 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strategies for Learning from Failure - Harvard Business Review
Reprint: R1104B Many executives believe that all failure is bad (although it usually provides lessons) and that learning from it is pretty straightforward....
Read more >
Troubleshooting a DHCP server failure - TechTarget
DHCP troubleshooting can be complicated. Use this troubleshooting guide to learn about common DHCP errors and how to fix them.
Read more >
20 Blogging Mistakes to Avoid in 2022, According to HubSpot ...
Below are common mistakes most beginners make and some tips on how to avoid them. Why do bloggers fail? Bloggers fail because they...
Read more >
Tarkov unity crash - Vesuvio
Unity Crash Handler ca4d5af0be6f When I try to launch Zelter, the game crashes on the loading screen and I'm having trouble playing the...
Read more >
ESP8266 Troubleshooting Guide - Random Nerd Tutorials
In the mean time several thoughts come to mind and I'm wondering if something in the internal memory could have been overwritten in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found