def test_xml3(): ''' DryFriction ''' # --- buildModelXML loading from xml file --- oscillator = buildModelXML("./data/DryFriction.xml") # --- Get the simulation --- s = oscillator.simulation() k = 0 T = oscillator.finalT() t0 = oscillator.t0() h = s.timeStep() N = np.ceil((T - t0) / h) # --- Get the values to be plotted --- # . saved in a matrix dataPlot dataPlot = np.zeros((N + 1, 5)) print("Prepare data for plotting ... ") # For the initial time step: # time dataPlot[k, 0] = t0 # state q for the first dynamical system (ball) dsN = SK.dynamicalSystems(oscillator.nonSmoothDynamicalSystem().topology().dSG(0))[0].number() oscillo = oscillator.nonSmoothDynamicalSystem().dynamicalSystem(dsN) inter = SK.interactions(oscillator.nonSmoothDynamicalSystem().topology().indexSet(0))[0] dataPlot[k, 1] = oscillo.q()[0] # velocity for the oscillo dataPlot[k, 2] = oscillo.velocity()[0] dataPlot[k, 3] = inter.lambda_(1)[0] dataPlot[k, 4] = inter.lambda_(1)[1] # --- Compute elapsed time --- print("Computation ... ") # --- Time loop --- while k < N: # get current time step k += 1 # print( " Pas " << k # solve ... s.computeOneStep() # --- Get values to be plotted --- # time dataPlot[k, 0] = s.nextTime() # Oscillo: state q dataPlot[k, 1] = oscillo.q()[0] # Oscillo: velocity dataPlot[k, 2] = oscillo.velocity()[0] dataPlot[k, 3] = inter.lambda_(1)[0] dataPlot[k, 4] = inter.lambda_(1)[1] # transfer of state i+1 into state i and time incrementation s.nextStep() # Number of time iterations print("Number of iterations done: {:}".format(k)) # dataPlot (ascii) output np.savetxt("DryFriction.dat", dataPlot)