Skip to content

Instantly share code, notes, and snippets.

@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([
@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 / 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 / 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 / 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 / button.html
Created February 12, 2023 22:21
Change button text onclick and show/hide element.
<script>
function toggleHidden() {
document.getElementById("solution").classList.toggle('hidden');
if ( document.getElementById("solution").classList.contains('hidden') ) {
document.querySelector('#btn').innerText = 'Показать решение';
} else {
document.querySelector('#btn').innerText = 'Скрыть решение';
}
}
</script>
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 / ftr-a-mu.py
Created February 7, 2022 20:04
Plot friction force vs. angle
import numpy as np
# Triginometry {{{
def cos(x): return round( np.cos( np.radians(x) ), 10 )
def sin(x): return round( np.sin( np.radians(x) ), 10 )
def tg(x): return round( np.tan( np.radians(x) ), 10 )
def arctg(x): return np.degrees( np.arctan(x) )
def sins(x): return round( np.sin( np.radians(x) )**2, 10 )
def asin(x): return np.degrees( np.arcsin(x) )
#}}}
import numpy as np
def cos(x):
return round( np.cos( np.radians(x) ), 10 )
def sin(x):
return round( np.sin( np.radians(x) ), 10 )
def asin(x):
return np.degrees( np.arcsin(x) )
# Plot setup {{{