Subida inicial del proyecto

main
Gabriel Quispe 2 months ago
parent 129375d321
commit 565c77213c
  1. 29
      Codigo2D_AjusteHelfrich.py
  2. 45
      Codigo2D_Coefs.py
  3. 16
      Codigo2D_Ejemplo.py
  4. 32
      Codigo3D_AjusteHelfrich.py
  5. 2
      Codigo3D_Ejemplo.py
  6. 9
      readme.txt.txt
  7. 25
      resumen.txt.txt

@ -1,40 +1,29 @@
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):
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):
def aproxHelfrich(x, y, T):
x = np.array(x)
y = np.array(y)
kbT = kb * T
try:
def model_fixedT(x, bend, stretch):
return helfrich_model(x, bend, stretch, kbT)
popt, _ = curve_fit(helfrich_model, x, y, p0=[1.4e-19, 1e-7]) # valores referencia
try:
popt, _ = curve_fit(model_fixedT, x, y, p0=[1.4e-19, 1e-7])
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
return abs(bend), abs(stretch)
except RuntimeError:
print("Error: La optimización no convergió")
return None, None

@ -10,42 +10,35 @@ import matplotlib.pyplot as plt
import Codigo2D_Base as c7
import Codigo2D_AjusteHelfrich as c8
# %% FUNCION TEORICA
kb = 1.380649*10**-23
T = 300
kbT = kb*T
# %% CONSTANTES
kb = 1.380649e-23 # J/K
valor = 10*kbT # este es el valor que deberia tener el bending
def fx(x,stretch,bend):
y = kbT*(0.5/stretch)*((1/x) - (stretch/bend + x**2)**(-0.5))
# %% FUNCION TEORICA
def fx(x, stretch, bend, T):
kbT = kb * T
y = kbT * (0.5 / stretch) * ((1 / x) - (stretch / bend + x**2) ** -0.5)
return y
# %% CODIGO
def calculatecoefs(MSph, nmin, nmax, T):
"""
Se utiliza el método de trapecios
"""
def calculatecoefs(MSph, nmin, nmax):
'''
Se utiliza el metodo de trapecios
'''
qx,u = c7.f2(MSph,21,positive = "Yes") # TODOS LOS COEFICIENTES (U) del 1 al 20
'''
El bending solo se calcula para ciertos modos
'''
qx, u = c7.f2(MSph, 21, positive="Yes") # TODOS LOS COEFICIENTES (U) del 1 al 20
# El bending solo se calcula para ciertos modos
qxnew = qx[nmin:nmax]
unew = u[nmin:nmax]
bend,stretch = c8.aproxHelfrich(qxnew,unew)
qxcont = np.linspace(qxnew[0],qxnew[-1],100) # limites coinciden con qx, pero Y no tiene porque es un ajuste no hay restriccion
Ycont = fx(qxcont,stretch,bend) # Al representar sera en el eje x: qxnew y en el y: Y
bend, stretch = c8.aproxHelfrich(qxnew, unew, T)
qxcont = np.linspace(qxnew[0], qxnew[-1], 100)
Ycont = fx(qxcont, stretch, bend, T)
kbT = kb * T
print("----------------")
print(f"Para modos entre {nmin+1} y {nmax+1} se obtiene:")
print("Bending (en uds kbT): ",bend/kbT)
print("Stretching [N/m]: ",stretch)
print("Bending (en uds kbT): ", bend / kbT)
print("Stretching [N/m]: ", stretch)
return qx,u,qxcont,Ycont,bend,stretch
return qx, u, qxcont, Ycont, bend, stretch

@ -9,6 +9,7 @@ import Codigo2D_FiltroZ as c1
import Codigo2D_Interpolacion as c2
import Codigo2D_Coefs as c3 # Este incluye a ajuste de Helfrich y a Base
T = 300 # temperatura
time = 50 # tiempo para graficar
# %% PROGRAMA ARIN
@ -37,17 +38,16 @@ MCart[:,:,2] = 0
# %% CALCULO DE BENDING Y STRETCH
nmax = 19
nmin = 4 # NOTA nmin = 0, es el modo 1
qx,u,qxnew,unew,bend,stretch = c3.calculatecoefs(MSph,nmin,nmax)
qx,u,qxnew,unew,bend,stretch = c3.calculatecoefs(MSph,nmin,nmax,T)
# %% GRAFICA
# plt.figure()
# plt.loglog(qx,u,marker = "o", color = "blue",linestyle = "none")
# plt.loglog(qxnew,unew,color="red", linestyle="-.")
plt.figure()
plt.plot(qx[nmin:nmax],u[nmin:nmax],marker = "o",color = "blue")
plt.plot(qxnew,unew,color="red", linestyle="-.")
plt.title("Coeficientes en función de qx", fontweight="bold")
plt.xlabel("qx", fontweight="bold")
plt.ylabel(r"$\langle \mathbf{|u|^2} \rangle$", fontsize=14)
# GRAFICA FILTRO (Simplemente para ver forma)
@ -62,9 +62,9 @@ z1_label = f"$\Delta z_1$ = {np.format_float_scientific(Z1, precision=2)}"
plt.plot(FiltroEsfmask[:,2], FiltroEsfmask[:,0], marker="h", linestyle="none", color="red", label=z1_label)
plt.title("Datos simulaciones filtro", fontweight="bold")
plt.xlabel("qx", fontweight="bold")
plt.ylabel(r"$\langle \mathbf{|u|^2} \rangle$", fontsize=14)
plt.title("Radio en función de phi", fontweight="bold")
plt.xlabel("PHI", fontweight="bold")
plt.ylabel("R [m]", fontweight = "bold")
plt.legend()
plt.show()

@ -3,37 +3,25 @@ import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
# %% AJUSTE
kb = 1.380649e-23 # J/K
kb = 1.380649e-23 # Constante de Boltzmann
T = 300 # Temperatura en Kelvin
kbT = kb * T # Factor kb * T
def helfrich_model(x, kappa, b):
# b = abs(b)
def helfrich_model(x, kappa, b, kbT):
kappa = abs(kappa)
b = abs(b)
return kbT / (8 * b + kappa * x)
result = kbT / (8*b + kappa*x)
return result
def aproxHelfrich(x, y):
def aproxHelfrich(x, y, T):
x = np.array(x)
y = np.array(y)
kbT = kb * T
try:
def model_fixedT(x, kappa, b):
return helfrich_model(x, kappa, b, kbT)
popt, _ = curve_fit(helfrich_model, x, y, p0=[1.4e-19, 1e-7]) # valores referencia
try:
popt, _ = curve_fit(model_fixedT, x, y, p0=[1.4e-19, 1e-7])
kappa, b = popt
# Aseguramos que bend y stretch sean siempre positivos
b = abs(b)
kappa = abs(kappa)
# # Establecemos un límite inferior para el valor de 'bend'
# bend = max(bend, 1e-20)
return kappa, b
return abs(kappa), abs(b)
except RuntimeError:
print("Error: La optimización no convergió")
return None, None

@ -33,7 +33,7 @@ maximo = 6 # corresponde a l = 5, pero luego sumamos 1 y es l = 6
coefs = a2l[minimo:maximo+1] # coeficientes entre l = 2, l = 6
valorx = terminol[minimo:maximo+1]/(r0*r0) # x de la funcion
kappa,b = c3.aproxHelfrich(valorx,coefs)
kappa,b = c3.aproxHelfrich(valorx,coefs,T)
bending = kappa/kbT
stretching = b

@ -0,0 +1,9 @@
El archivo de las simulaciones usado es "matrizcartesianas.npy" (modificar variando T y xi)
- Los archivos de "..._Ejemplo.py" son los que hay que ejecutar (cambiando el archivo de simulaciones)
- Cuando se varía T de las simulaciones, se tiene que modificar "..._Ejemplo.py" (linea 15 en 3D, linea 12 en 2D)
- En el caso 3D el análisis se hace hasta Lmax = 20, y el análisis posterior se hace entre l = 2 y l = 6 (se puede variar en las líneas 26,30,31)
- En el caso 2D, se realiza el análisis hasta un 1% del radio promedio (en z, linea 29 modificable), y se analiza entre n = 5, y n = 20 (modificable en linea 39,40)

@ -0,0 +1,25 @@
En estos códigos se realiza el análisis en 2D y 3D de la membrana.
# %% CASO 2D
2D: https://link.springer.com/article/10.1140/epje/i2004-10001-9 (Ajuste a Ec.11)
En el caso 2D se eligen valores cercanos al origen y se proyectan sobre el plano Z = 0
Se interpolan los datos de forma equiespaciada
Mediante integración por trapecios se obtienes los coeficientes
Se obtienen los valores medios y se ajustan a la ecuación
# %% CASO 3D
3D: https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.106.188101 (Ajuste a Ec.7)
- Proyección sobre grid icosaédrico
- Expansion mediante armónicos esféricos (de variación con respecto a superficie promedio)
- Calculo de valores medios
- Se obtienen los valores medios y se ajustan a la ecuación
Loading…
Cancel
Save