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

flist.to_dataframe() fails #828

Closed
germa89 opened this issue Jan 12, 2022 · 1 comment · Fixed by #832
Closed

flist.to_dataframe() fails #828

germa89 opened this issue Jan 12, 2022 · 1 comment · Fixed by #832
Assignees

Comments

@germa89
Copy link
Collaborator

germa89 commented Jan 12, 2022

Describe the bug
The conversion to data frame fails in the following example. Maybe because of low number of nodes?

To Reproduce

import matplotlib.pyplot as plt
import numpy as np

from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl()

mapdl.prep7()
mapdl.units("SI")  # SI - International system (m, kg, s, K).

# define a PLANE183 element type with thickness
mapdl.et(1, "PLANE183", kop3=3)
mapdl.r(1, 0.001)  # thickness of 0.001 meters)

# Define a material (nominal steel in SI)
mapdl.mp("EX", 1, 210e9)  # Elastic moduli in Pa (kg/(m*s**2))
mapdl.mp("DENS", 1, 7800)  # Density in kg/m3
mapdl.mp("NUXY", 1, 0.3)  # Poisson's Ratio

# list currently defined material properties
print(mapdl.mplist())

length = 0.4
width = 0.1

ratio = 0.3  # diameter/width
diameter = width * ratio
radius = diameter * 0.5


# create the rectangle
rect_anum = mapdl.blc4(width=length, height=width)

# create a circle in the middle of the rectangle
circ_anum = mapdl.cyl4(length / 2, width / 2, radius)

# Note how pymapdl parses the output and returns the area numbers
# created by each command.  This can be used to execute a boolean
# operation on these areas to cut the circle out of the rectangle.
plate_with_hole_anum = mapdl.asba(rect_anum, circ_anum)

# ensure there are at 50 elements around the hole
hole_esize = np.pi * diameter / 50  # 0.0002
plate_esize = 0.01

# increased the density of the mesh at the center
mapdl.lsel("S", "LINE", vmin=5, vmax=8)
mapdl.lesize("ALL", hole_esize, kforc=1)
mapdl.lsel("ALL")

# Decrease the area mesh expansion.  This ensures that the mesh
# remains fine nearby the hole
mapdl.mopt("EXPND", 0.7)  # default 1

mapdl.esize(plate_esize)
mapdl.amesh(plate_with_hole_anum)


# Fix the left-hand side.
mapdl.nsel("S", "LOC", "X", 0)
mapdl.d("ALL", "UX")

# Fix a single node on the left-hand side of the plate in the Y
# direction.  Otherwise, the mesh would be allowed to move in the y
# direction and would be an improperly constrained mesh.
mapdl.nsel("R", "LOC", "Y", width / 2)
assert mapdl.mesh.n_node == 1
mapdl.d("ALL", "UY")

# Apply a force on the right-hand side of the plate.  For this
# example, we select the nodes at the right-most side of the plate.
mapdl.nsel("S", "LOC", "X", length)

# Verify that only the nodes at length have been selected:
assert np.allclose(mapdl.mesh.nodes[:, 0], length)

# Next, couple the DOF for these nodes.  This lets us provide a force
# to one node that will be spread throughout all nodes in this coupled
# set.
mapdl.cp(5, "UX", "ALL")

f = open('Node_disp_xy45.txt', 'a')
for ii in range(0, 1):
   # Select a single node in this set and apply a force to it
   # We use "R" to re-select from the current node group
   mapdl.nsel("R", "LOC", "Y", width / 2)    
   mapdl.f("ALL", "FY", 10+10*ii)

   # finally, be sure to select all nodes again to solve the entire solution
    _ = mapdl.allsel()

    mapdl.run("/SOLU")
    mapdl.antype("STATIC")
    output = mapdl.solve()
    print(output)

   # grab the result from the ``mapdl`` instance
    result = mapdl.result
    # result.plot_principal_nodal_stress(
    #     0, "SEQV", lighting=False, cpos="xy", background="w", text_color="k",
    #     add_text=False)
    np.savetxt(f, result.nodal_displacement(0)[1])

f.close()
@germa89 germa89 added the Bug label Jan 12, 2022
@germa89 germa89 self-assigned this Jan 12, 2022
@germa89
Copy link
Collaborator Author

germa89 commented Jan 13, 2022

It seems this also fails on Linux:

from ansys.mapdl.core import launch_mapdl
from ansys.mapdl.core import examples
mapdl = launch_mapdl()
example = examples.vmfiles['vm10']
mapdl.input(example)
mapdl.slashsolu()
mapdl.solve()
mapdl.post1()
cmd = mapdl.prnsol('U', 'X')
cmd.to_dataframe()

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

Successfully merging a pull request may close this issue.

1 participant