You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
memb_analisis_2d3d/Codigo2D_AjusteHelfrich.py

29 lines
770 B

import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
kb = 1.380649e-23 # Constante de Boltzmann
def helfrich_model(x, bend, stretch, kbT):
bend = abs(bend)
stretch = abs(stretch)
term = stretch / bend + x**2
result = kbT * (0.5 / stretch) * ((1 / x) - term ** -0.5)
return result
def aproxHelfrich(x, y, T):
x = np.array(x)
y = np.array(y)
kbT = kb * T
def model_fixedT(x, bend, stretch):
return helfrich_model(x, bend, stretch, kbT)
try:
popt, _ = curve_fit(model_fixedT, x, y, p0=[1.4e-19, 1e-7])
bend, stretch = popt
return abs(bend), abs(stretch)
except RuntimeError:
print("Error: La optimización no convergió")
return None, None