
library std.math {

    pi = 3.141592653
    e =  2.718281828


    sin(x) = __sin__(x)
    cos(x) = __cos__(x)
    tan(x) = __tan__(x)

    sinh(x) = __sinh__(x)
    cosh(x) = __cosh__(x)
    tanh(x) = __tanh__(x)

    asin(x) = __asin__(x)
    acos(x) = __acos__(x)
    atan(x) = __atan__(x)
    atan2(x,y) = __atan2__(x=x,y=y)

    exp(x) = __exp__(x)
    ln(x) = __ln__(x)
    log2(x) = __log2__(x)
    log10(x) = __log10__(x)

    abs(x) = __abs__(x)
    #sqrt(x) = __sqrt__(x)


    # Expected to be dimensionless:
    pow(base,exp) = __pow__(base=base,exp=exp)

    # Allow integer numerator and 
    # denominator:
    #powint(x,n,d) = __powint__(x=x,n=n,d=d)
    #sqrt(x) = __sqrt__(x)

    ceil(x) = __ceil__(x)
    fabs(x) = __fabs__(x)
    floor(x) = __floor__(x)
    
    #min(x,y) = __min__(x=x,y=y)
    #max(x,y) = __max__(x=x,y=y)
    #fabs(x,y) = __fabs__(x=x)
    
}




library std.geom {
    from std.math import pi

    area_of_sphere(r:{m}) = 4 * pi * r*r
    volume_of_sphere(r:{m}) = 4.0/3.0 * pi * r*r *r
}


library std.neuro {
    from std.math import pi,pow
    
	
	# Linear Cable Theory (Koch Pg.32):
    r_a(R_i:{ohm m}, d:{m}) = (4*R_i)/(pi*d*d)
    
    # Nasty hack to get around exponents and dimensions problem:
    #space_constant(Rm:{ohm m2},Ri:{ohm m},d:{m}) = powint(base=(Rm/Ri)*(d/4),n=1,d=2)
    #space_constant(Rm:{ohm m2},Ri:{ohm m},d:{m}) = sqrt(base= (Rm/Ri)*(d/4) )
    space_constant(Rm:{ohm m2},Ri:{ohm m},d:{m}) = pow(base=(( (Rm/Ri)*(d/4) )/{1m2}),exp=0.5) * {1m}

    Rinf_sealed_end(Rm:{ohm m2},d:{m}) = (4*Rm/(pi*d*d) )


    # Expressions for defining forward and backward rate constants:
    RateConstant5(V:{V},a1:{s-1} ,a2:{V-1 s-1}, a3:{},a4:{V},a5:{V} ) = (a1 + a2*V)/(a3+std.math.exp( (V+a4)/a5) )

}


library std.physics {
    
    F = 96485.3365 coulomb mole-1
    Na = 6.02214129e23 mole-1
    k = 1.380648e-23 joule kelvin-1
    e =  1.602176565 coulomb
    R = 8.3144621 J mole-1 kelvin-1
    #R = 8.3144621 J/(mole kelvin)
}

 
