Skip to content

Instantly share code, notes, and snippets.

import numpy as np
from sympy import *
from scipy import interpolate
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams
# Plot and save trajectories y(x) for fixed v0, k and varying
# angle α.
# Last line prints an angle corresponding to the maximum length
@pozitron57
pozitron57 / 878.py
Last active October 27, 2023 12:33
x(t) and T(t) for adiabatic piston on the gas oscillations in the elevator (https://phys.pro/problems/878/)
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams
from scipy.integrate import solve_ivp
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import MultipleLocator
# Plot setup {{{
from matplotlib import rc, rcParams
@pozitron57
pozitron57 / 881.py
Created November 6, 2023 00:37
alpha(t) for ring oscillations https://phys.pro/problems/881/
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams
from scipy.integrate import solve_ivp
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import MultipleLocator
# Plot setup {{{
lw = 2
@pozitron57
pozitron57 / 237-gif.py
Created November 15, 2023 14:51
Animation F_friction(t) plot for phys.pro/problems/237/
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import MultipleLocator
# Set parameters
m = 2 # kg
@pozitron57
pozitron57 / 237.py
Last active November 15, 2023 19:45
F_friction(t) plot for phys.pro/problems/237/
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import MultipleLocator
# Plot setup {{{
lw = 2
k=1.4
@pozitron57
pozitron57 / 947.py
Last active December 18, 2023 20:31
Carnot cycle in problem #947 at https://phys.pro/problems/947
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams
lw=2.5
rcParams['font.size'] = 26
rc('axes', linewidth=1)
rc('xtick.major', size=7, width=lw/1.3)
rc('ytick.major', size=7, width=lw/1.3)
rc('xtick.minor', size=0, width=lw/2.5)
@pozitron57
pozitron57 / ege-scale-2024.py
Created March 27, 2024 20:27
Шкала перевода первичных баллов в тестовые для ЕГЭ по физике 2024 года
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams
from matplotlib.ticker import AutoMinorLocator, MultipleLocator
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.size": 23,
"text.latex.preamble": "\n".join([