Why does the vibrational module graph show blue zones?

56 Views Asked by At

Title: Vibrations in a Structure Excited - Determination of Damping Coefficient

The objective of this practical work is to determine the damping coefficient to prevent excessive vibrations in a structure subjected to cyclic loading.

Initial Value Problem:

You will solve the differential equation given by Newton's second law to obtain the position, velocity, and acceleration. You should select a calculation step of at least 500 points per cycle. The initial value problem will be solved using the method specified by the group. Obtaining the Desired Damping Coefficient:

Define a function "f(x)" where "x" represents the value of "C," and "f(x)" represents the desired amplitude. The value of the function is obtained through a run of the initial value problem algorithm. The value of the damping coefficient "C" should be obtained with three significant correct digits. The report should follow the following structure: A. Cover Page B. Introduction, including objectives, and a summary of the work (maximum 1 page). C. Work Development; include figures and tables where appropriate. D. Conclusions, especially regarding the value of the damping coefficient. E. Annex I: Source code - you can attach the Python file or provide a link to a collaborative platform where it was developed.

Upload the report and code to the appropriate task on the campus platform.

Here are the equations of the Bashford method defined:

enter image description here

values:

  • K = 615 N/mm
  • m = 9.7 ton
  • Fm = 850 N
  • xadm = 1.25 mm
  • P = 0.7890929760279801 s

characteristics :

The structure is given a force which is applied from 0 To P/10 then 9P/10 s Without any force and on P is again applied. If xMax calculated< Xadm return C. C should be calculated using Secant Method. But at this moment im just trying to make the different graphs and I got this results with this code:

from decimal import Decimal
from typing import List

import numpy as np
import matplotlib.pyplot as plt

m = Decimal(9700)
K = Decimal(615)
F = Decimal(850)
x_adm = Decimal(0.00125)
P = Decimal(0.7890929760279801)
c = Decimal(1) #test value


def force_periodic(x, P, F):  # gives the value of F in x time
    normalized_x = Decimal(x) % P  # Normalize x to the range [0, P)
    if x < 0: return Decimal(0)
    if normalized_x < P / 10:
        return F
    else:
        return Decimal(0)


class Vibrations:
    def __init__(self, m, K, x_adm, P, F):
        self.m = m
        self.K = K
        self.x_adm = x_adm
        self.P = P
        self.F = F

    t_points = np.linspace(0, float(2 * P), 1000)
    F_points = [force_periodic(xi, P, F) for xi in t_points]
    x_points: List[Decimal] = [Decimal(0)]
    v_points: List[Decimal] = [Decimal(0)]
    a_points = [0]

    def f(self, i):
        if i < 0: return 0
        if i == 0: return F / m
        return self.F_points[i] / m - K * self.x_points[i] - c * self.v_points[i]

    def Adams_BashfordSpeed(self, i):
        if i <= 0:
            self.v_points.append((P / 1000) * (3 * self.f(i - 1) - self.f(i - 2)))
        else:
            self.v_points.append(self.v_points[i - 1] + (P / 1000) * (3 * self.f(i - 1) - self.f(i - 2)))

    def Adam_BashfordXpos(self, i):
        if i <= 0:
            self.x_points.append((P / 1000) * (3 * self.v_points[i - 1] - self.v_points[i - 2]))
        else:
            self.x_points.append(self.x_points[i - 1] + (P / 1000) * (3 * self.v_points[i - 1] - self.v_points[i - 2]))

    def calculate(self):
        for x in range(len(self.t_points) - 1):
            self.Adams_BashfordSpeed(x)
            self.Adam_BashfordXpos(x)

    def graph(self):
        plt.plot(self.t_points, self.F_points, label='Force')
        plt.xlabel('Time')
        plt.ylabel('Force')
        plt.legend()
        plt.show()
        plt.plot(self.t_points, self.v_points, color='blue', label='V(t)',drawstyle='steps')
        plt.plot(self.t_points, self.x_points, color='Red', label='X(t)',drawstyle='steps')
        plt.legend()
        plt.show()


if __name__ == '__main__':
    vibrations = Vibrations(m, K, x_adm, P, F)
    vibrations.calculate()
    print(len(vibrations.t_points))
    print(len(vibrations.x_points))
    print(len(vibrations.v_points))
    vibrations.graph()

F(t)

V(t) & X(t)

on V(T) graph I don't know why it creates blue areas. That is the main problem I don't know if it's either not defining a punctual value or plotting bad the graph.

I tried all that code changing variables I dont know what is wroken the logic or the code .

1

There are 1 best solutions below

1
Trenton McKinney On

This assumes the math functions are correct.

If the linestyle and markersize of the two plots are changed, you can see there are essentially two signals for both the red and blue lines, and lines are connecting all of the data points.

Either remove the lines, or switch to a scatter plot.

Remove linestyle and add marker

def graph(self):
    plt.plot(self.t_points, self.F_points, label='Force')
    plt.xlabel('Time')
    plt.ylabel('Force')
    plt.legend()
    plt.show()
    # used explicit interface to control figure size
    fig, ax = plt.subplots(figsize=(20, 20))
    # update to remove linestyle and use a marker
    ax.plot(self.t_points, self.v_points, marker='.', color='blue', label='V(t)', drawstyle='steps', ls='')
    # update to remove linestyle and use a small marker
    ax.plot(self.t_points, self.x_points, marker='.', color='Red', label='X(t)', drawstyle='steps', ls='', markersize=0.5)
    plt.legend()
    plt.show()

Use .scatter

def graph(self):
    plt.plot(self.t_points, self.F_points, label='Force')
    plt.xlabel('Time')
    plt.ylabel('Force')
    plt.legend()
    plt.show()
    # used explicit interface to control figure size
    fig, ax = plt.subplots(figsize=(20, 20))
    # changed to scatter plot
    ax.scatter(self.t_points, self.v_points, color='blue', label='V(t)')
    # changed to scatter plot
    ax.scatter(self.t_points, self.x_points, color='Red', label='X(t)', s=0.5)
    plt.legend()
    plt.show()

enter image description here