Created
August 2, 2019 20:43
-
-
Save rnwatanabe/f0ae57b2228b4d240193862c21c0ba99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class Musculo: | |
def __init__(self, Fmax, Lceopt, LslackSE, | |
LslackPE, alpha, Tact, Tdeact, FMlen, VMmax, | |
Lce0, dt): | |
''' | |
Inputs: | |
alpha: float, (rad) | |
Tact: float, (ms) | |
Tdeact: float, (ms) | |
''' | |
self.Fmax = Fmax | |
self.Lceopt = Lceopt | |
self.LslackSE = LslackSE | |
self.kse = self.Fmax/(0.04*self.LslackSE)**2 | |
self.LslackPE = LslackPE | |
self.kpe = 5.0 | |
self.epsilon0 = 0.6 | |
self.alpha = alpha | |
self.Tact = Tact/1000 #[s] | |
self.Tdeact = Tdeact/1000 #[s] | |
self.FMlen = FMlen | |
self.VMmax = VMmax | |
self.a = 0.01 | |
self.Lcenorm = Lce0/self.Lceopt | |
self.Fcenorm = 0.0 | |
self.Lsenorm = 0.0 | |
self.Fpenorm = 0.0 | |
self.Fsenorm = 0.0 | |
self.F0 = 0.0 | |
self.b = 0.0 | |
self.dt = dt | |
def calculoComprSerie(self, Lmtnorm): | |
self.Lsenorm = Lmtnorm - self.Lcenorm*np.cos(self.alpha) | |
def computaForcaParalelo(self): | |
self.Fpenorm = (np.exp(self.kpe*(self.Lcenorm - 1)/self.epsilon0) - 1)/(np.exp(self.kpe - 1)) | |
def computaForcaSerie(self): | |
if self.Lsenorm >= self.LslackSE/self.Lceopt: | |
self.Fsenorm = self.kse*(self.Lsenorm - self.LslackSE/self.Lceopt)**2/self.Fmax*self.Lceopt**2 | |
else: | |
self.Fsenorm = 0.0 | |
def computaForcaCE(self): | |
self.Fcenorm = (self.Fsenorm - self.Fpenorm*np.cos(self.alpha))/np.cos(self.alpha) | |
def curvaForcaCompr(self): | |
self.F0 = np.exp(-(self.Lcenorm-1)**2/0.45) | |
def calculo_a(self, u): | |
if u > self.a: | |
tau = self.Tact*(0.5 + 1.5*self.a) | |
else: | |
tau = self.Tdeact/(0.5 + 1.5*self.a) | |
dadt = (u - self.a)/tau | |
self.a = self.a + self.dt*dadt | |
def calculo_b(self): | |
if self.Fcenorm > self.a*self.F0: | |
self.b = (2 + 2/0.25)*((self.a*self.F0*self.FMlen) - self.Fcenorm)/(self.FMlen - 1) | |
else: | |
self.b = self.a*self.F0 + (self.Fcenorm/0.25) | |
def ComprimentoCE(self): | |
dLcenormdt = (0.25+0.75*self.a)*self.VMmax*(self.Fcenorm - self.a*self.F0)/self.b | |
self.Lcenorm = self.Lcenorm + self.dt*dLcenormdt | |
def atualizaMusculo(self, Lmt, u): | |
Lmtnorm = Lmt/self.Lceopt | |
self.calculoComprSerie(Lmtnorm) | |
self.computaForcaParalelo() | |
self.computaForcaSerie() | |
self.computaForcaCE() | |
self.curvaForcaCompr() | |
self.calculo_a(u) | |
self.calculo_b() | |
self.ComprimentoCE() | |
F = self.Fsenorm * self.Fmax | |
return F |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment