General Mechanical

General Mechanical

Topics relate to Mechanical Enterprise, Motion, Additive Print and more

Read data inbetween loadsteps of transient analysis

    • Mathijs Verbist
      Subscriber

      Hi, I'm working on a transient analysis in (Py)MAPDL and I would like to read data inbetween loadsteps and continue after with a new loadstep. But when I go from /POST26 (to read the output) to /SOLU again and solve a new loadstep, the states (speed and displacement) of the previous loadstep are deleted and the simulation is started from 0. How can I make sure that the previous timestep is taken into account after exiting /POST26 to /SOLU?
      Do I have to use initial conditions for the next step, or is there an option to keep the previous step?

      /SOLU

      !D, 20, ALL
      D, 20, ROTY
      D, 20, ROTZ
      D, 20, ROTX

      F, 20, MX, 0
      ANTYPE, TRANS

      NSUBST, 10,10,10
      OUTRES, ALL, ALL
      KBC, 1

      F, 1, MX, 10
      time, 1
      lswrite, 1
      solve

      /POST26 !this step is needed for external processing and updating the loads in the next step

      NSOL, 2, 1, ROT, X, ROTX
      NSOL, 3, 1, OMG, X, ROTVELX

      /SOLU
      F, 1, MX, 100 !value here is dependant on the previous solutions
      time, 2
      lswrite, 2
      solve

    • Erik Kostson
      Ansys Employee

      Hi

      Perhaps use restart option.

      Example

      end_time = arg1 ! WB parameters
      step = arg2
      substep = arg3
      limpres = arg4
      delta_t = end_time/step                                                ! time increment
      save,model,db                                                                  ! (database saved for diagnosing purpose)
       
      /solu
      antype,4                                                                              ! transient analysis
      autots,off                 ! User turned off automatic time stepping
      timint,on
      time,1e-5                                                                            ! a very small initial time
      alls
      solve
      *do,i,1,step,1                                                    ! loop substep number
        fini
        /post1
        set,i                                                                     ! read ith step
        !do something here
        allsel,all
        fini
        parsav,all,my_par,txt                                    ! save paramters
       
        /solu
        antype,4,rest                                                   ! restart from last step
        timint,on
        autots,off                 ! User turned off automatic time stepping
        parres,new,my_par,txt                                 ! resume parameter
        time,i*delta_t
        nsubst,substep
        !do something here
        /solu
       
        alls
        solve
      *enddo
      Hope this helps
      Erik
      • Mathijs Verbist
        Subscriber

        Hi Erik, thank you for responding. 
        It think it works in MAPDL itself, but when tested with PyMAPDL, it now only solves the first loadstep. Figure 1 is what the codes returns, while it is supposed to look like figure 2 after the second load step. (Figure 2 is created without going into POST26 and without restarting the solution)

         

        This is the code I run now:

        mapdl.slashsolu()
        mapdl.keep(1)
        #mapdl.d(20, "ALL")
        mapdl.d(20, "ROTY")
        mapdl.d(20, "ROTZ")
        #mapdl.d(20, "ROTX")

        timesteps = 2
        substeps = 10
        substeps_max = 10
        substeps_min = 10

        mapdl.run("ANTYPE, TRANS")
        mapdl.timint("ON")
        mapdl.autots("OFF")
        mapdl.nsubst(substeps, substeps_max, substeps_min)
        mapdl.outres("ALL", "ALL")
        mapdl.kbc(1)

        #mapdl.d(20, "ALL")
        mapdl.d(20, "ROTY")
        mapdl.d(20, "ROTZ")
        #mapdl.d(20, "ROTX")

        mapdl.f(1, "MX", 10)
        mapdl.time(1)
        mapdl.lswrite(1)
        mapdl.solve()

        mapdl.post26()
        rot_displ = mapdl.nsol(2, 1, "ROT", "X", "ROTX")
        #print(rot_displ)
        mapdl.allsel("all")
        mapdl.finish
        mapdl.parsav("all","my_par","txt")
        mapdl.slashsolu()
        mapdl.antype(4,"REST")
        mapdl.timint("ON")
        mapdl.autots("OFF")
        mapdl.parres("new","my_par","txt")

        mapdl.f(1, "MX", -10)
        mapdl.slashsolu()
        mapdl.time(2)
        mapdl.lswrite(2)  
        mapdl.solve()

        mapdl.post26()
        rot_displ = mapdl.nsol(2, 1, "ROT", "X", "ROTX")
        #print(rot_displ)

        # Plot nodal displacement against time
        plt.plot( rot_displ, marker='o', linestyle='-')
        plt.xlabel('Time (seconds)')
        plt.ylabel('Nodal rotation')
        plt.title('Nodal rotation vs. Time')
        plt.grid(True)
        plt.show()

        mapdl.exit()
    • Mathijs Verbist
      Subscriber

      I got is working by using the restart in combination with lssolve, i ,i ,1 instead of just using solve. Now all the steps get solved while getting the data inbewteen the steps

Viewing 2 reply threads
  • You must be logged in to reply to this topic.