Skip to content

Instantly share code, notes, and snippets.

View carlos-adir's full-sized avatar

Carlos Adir carlos-adir

View GitHub Profile
@carlos-adir
carlos-adir / CompareNumericalConvergence.py
Created November 25, 2022 01:12
This file has many functions that can iterate and plots the final result for convergence, precision is also a input
import numpy as np
import sympy as sp
from matplotlib import pyplot as plt
import mpmath as mp
mp.mp.dps = 4000
print(mp.mp)
sqrt = mp.sqrt
def xsqrta(x, a):
@carlos-adir
carlos-adir / Exercise1.py
Last active June 23, 2022 19:17
Vibrations exercices
import numpy as np
import sympy as sp
sin, cos = sp.sin, sp.cos
k1, k2 = sp.symbols("k1 k2", real=True, positive=True)
L1, L2 = sp.symbols("L1 L2", real=True, positive=True)
a, p, m= sp.symbols("a p m", real=True, positive=True)
theta = sp.symbols("theta")
dtheta = sp.symbols("dtheta")
@carlos-adir
carlos-adir / test_systemsolution.py
Created June 20, 2022 13:43
Block matrix reduce system for finite element
import numpy as np
import sympy as sp
from numpy import linalg as la
"""
https://mathoverflow.net/questions/425067/block-matrix-reduce-system-for-finite-element-method
"""
def random_sym_matrix(side):
F = np.random.rand(side, side)
@carlos-adir
carlos-adir / findcatenary.py
Last active April 24, 2022 17:04
This algorithm finds the solution of an non-linear equation. The equation is the catenary, which must pass the point (x0, y0). There are 0, 1 or 2 solutions for this problem
######################################
# Description #
######################################
#
# This algorithm finds the solution of an non-linear equation
# The equation is the catenary, that is like
# h(x) = a * cosh(x/a)
# We want to find the value of "a" such that h(x0) = y0
# Where (x0, y0) is known
#
@carlos-adir
carlos-adir / interface.py
Last active September 26, 2020 21:34
Ploting curves of Bode, Nichols and Nyquist using Tkinter as GUI and sympy to treat the expressions
import tkinter as tk
import negocio
import numpy as np
import matplotlib.ticker as ticker
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg
@carlos-adir
carlos-adir / sort_list.cpp
Created December 3, 2019 16:57
An algorithme to sort a liste
#include <iostream>
using namespace std;
struct elemento
{
int valor;
elemento *proximo;
};