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.
40 lines
976 B
40 lines
976 B
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from scipy.optimize import curve_fit
|
|
|
|
kb = 1.380649e-23 # Constante de Boltzmann
|
|
T = 300 # Temperatura en Kelvin
|
|
kbT = kb * T # Factor kb * T
|
|
|
|
def helfrich_model(x, bend, stretch):
|
|
|
|
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):
|
|
x = np.array(x)
|
|
y = np.array(y)
|
|
|
|
try:
|
|
|
|
popt, _ = curve_fit(helfrich_model, x, y, p0=[1.4e-19, 1e-7]) # valores referencia
|
|
bend, stretch = popt
|
|
|
|
# Aseguramos que bend y stretch sean siempre positivos
|
|
bend = abs(bend)
|
|
stretch = abs(stretch)
|
|
|
|
# # Establecemos un límite inferior para el valor de 'bend'
|
|
# bend = max(bend, 1e-20)
|
|
return bend, stretch
|
|
except RuntimeError:
|
|
print("Error: La optimización no convergió")
|
|
return None, None
|
|
|
|
|
|
|