Пример #1
0
from scipy import inf
from scipy.linalg import solve, inv, norm
from constants import w, d, E, I, L, beam_weight, p, g, sinus_force, exact_solution

e_mach = np.finfo(float).eps
y_exact = exact_solution(L)
y_numericalAtL = np.empty([11, 1], dtype=float)
n_values = np.empty([11, 1], dtype=int)
errorAtL = np.empty([11, 1], dtype=float)
theoreticalError = np.empty([11, 1], dtype=float)
condXEmach = np.empty([11, 1], dtype=float)

k = 1
while k <= 11:
    n = 10 * (2**k)
    A = create_matrix(n)
    b = np.ones(n)

    n_values[k - 1] = n

    h = L / n  # Lengden paa intervallet h er gitt ved lengden paa bjelken delt paa antall intervaller
    theoreticalError[k - 1] = (L**2) / (
        n**2)  # Teoretisk feil gitt ved h^2 = L^2/n^2

    factor = h**4 / (E * I)

    for i in range(n):
        b[i] = (
            sinus_force(h * (i + 1)) + beam_weight
        ) * factor  # Kraftmatrisen paa hoeyre side av likningen Ax = b.
Пример #2
0
from oppgave2 import create_matrix
import numpy as np
import math
import matplotlib.pyplot as plt
from constants import L, w, d, g, E, I, beam_weight
np.set_printoptions(precision=16)

if __name__ == "__main__":
    #antall intervaller
    n = 10.0

    #Oppretter A-matrisen
    A = create_matrix(int(n))

    #Lengden på et segment gitt n
    h = L / n

    factor = math.pow(h, 4) / (E * I)

    b_matrix = np.zeros(int(n))
    #Setter inn verdier til b-matrisen (kraft per segment)
    for i in range(0, int(n)):
        b_matrix[i] = beam_weight * factor

    #Løser likningssystemet
    print("Løsning av likningssystemet: ")
    answer = np.linalg.solve(A, b_matrix)
    newTab = [0]
    for i in range(0, 10):
        newTab.append(answer[i])
        print(answer[i])