-1

I have edited a python script based on an answer on another question but it still does not seem to run. I have a force load which causes a displacement. I want that after a certain amount of displacement, the force becomes zero. This is the code that I have so far based on this previous problem How to run a python script after every time step of a dynamic load in Ansys WB (transient analysis. I appreciate any advice and help:

model=ExtAPI.DataModel.Project.Model
firstAnalysis = model.Analyses[0]
solution = firstAnalysis.Solution

force_246=ExtAPI.DataModel.GetObjectById(246)

for loadstep in loadsteps:
    currentAnalysis = firstAnalysis.Duplicate()
    # Get the results from the last load step
    deformations = [item for item in solution.Children if item.GetType() == Ansys.ACT.Automation.Mechanical.Results.DeformationResults.DeformationResult]

    deformation1 = deformations.GetObjectById(53)

    for i in dis:
        if deformation1 >= 0.058:
            force_246.YComponent.Output.SetDiscreteValue(2.2, Quantity(0, "N"))
        


    solution = currentAnalysis.Solution

    solution.Solve(True)
thebatman
  • 1
  • 2
  • is seems that you are missing imports or variable definitions, so i cannot reproduce the problem... https://stackoverflow.com/help/minimal-reproducible-example – D.L Oct 01 '22 at 14:35

1 Answers1

0

I have an idea but I this will not work with every geometry. You don't apply the force directly on the target body but via a contact body:

  1. Create a body on the area where you applied the force. Apply the force on thisbody
  2. Connect the two bodies with a frictionless contact.
  3. Fix the contact body with a translational joint. The x-direction of the joint should point in the same direction as the force.
  4. Add a Stop to your joint. This way you limit the joint to the displacement you have in mind. This value can even be parameterized.

enter image description here

This will behave highly nonlinear, so expect convergence difficulties. Test this approach with a very small and simple subsection of your model.

meshWorker
  • 183
  • 2
  • 13