コード例 #1
0
ファイル: rpnPhysics.py プロジェクト: GaelicGrime/rpn
def calculateOrbitalVelocityOperator( measurement1, measurement2 ):
    '''
    To solve the velocity of a circular orbit, we need Newton's gravitational
    constant and two of the following three items:

    G = Newton's gravitational constant

    m = planetary mass (i.e., mass of the thing being orbited)
    r = orbit radius (the distance from the center of mass)
    T = orbital period

    ---- velocity in terms of mass and radius
    v = sqrt( G*m/r )

    ---- velocity in terms of radius and period
    v = 2*pi*r/T

    ---- velocity in terms of mass and period
    v = ( 2*pi*cbrt( T^2*G*m/4*pi^2 ) ) / T
    '''
    validUnitTypes = [
        [ 'mass', 'time' ],
        [ 'length', 'time' ],
        [ 'mass', 'length' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if not arguments:
        raise ValueError( '\'orbital_velocity\' requires specific measurement types (see help)' )

    if 'mass' in arguments:
        mass = arguments[ 'mass' ]

        if 'length' in arguments:
            bRadius = True
            radius = arguments[ 'length' ]
        else:
            bRadius = False
            period = arguments[ 'time' ]
    else:
        # radius and period
        radius = arguments[ 'length' ]
        period = arguments[ 'time' ]
        velocity = divide( getProduct( [ 2, pi, radius ] ), period )
        return velocity.convert( 'meter/second' )

    if bRadius:
        # mass and radius
        velocity = getRoot( divide( multiply( getConstant( 'newton_constant' ), mass ), radius ), 2 )
    else:
        # mass and period
        term = divide( getProduct( [ period, period, getConstant( 'newton_constant' ), mass ] ),
                       getProduct( [ 4, pi, pi ] ) )

        velocity = divide( getProduct( [ 2, pi, getRoot( term, 3 ) ] ), period )

    return velocity.convert( 'meter/second' )
コード例 #2
0
ファイル: rpnPhysics.py プロジェクト: ConceptJunkie/rpn
def calculateOrbitalVelocity( measurement1, measurement2 ):
    '''
    To solve the velocity of a circular orbit, we need Newton's gravitational
    constant and two of the following three items:

    G = Newton's gravitational constant

    m = planetary mass (i.e., mass of the thing being orbited)
    r = orbit radius (the distance from the center of mass)
    T = orbital period

    ---- velocity in terms of mass and radius
    v = sqrt( G*m/r )

    ---- velocity in terms of radius and period
    v = 2*pi*r/T

    ---- velocity in terms of mass and period
    v = ( 2*pi*cbrt( T^2*G*m/4*pi^2 ) ) / T
    '''
    validUnitTypes = [
        [ 'mass', 'time' ],
        [ 'length', 'time' ],
        [ 'mass', 'length' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if not arguments:
        raise ValueError( '\'orbital_velocity\' requires specific measurement types (see help)' )

    if 'mass' in arguments:
        mass = arguments[ 'mass' ]

        if 'length' in arguments:
            bRadius = True
            radius = arguments[ 'length' ]
        else:
            bRadius = False
            period = arguments[ 'time' ]
    else:
        # radius and period
        radius = arguments[ 'length' ]
        period = arguments[ 'time' ]
        velocity = divide( getProduct( [ 2, pi, radius ] ), period )
        return velocity.convert( 'meter/second' )

    if bRadius:
        # mass and radius
        velocity = getRoot( divide( multiply( getConstant( 'newton_constant' ), mass ), radius ), 2 )
    else:
        # mass and period
        term = divide( getProduct( [ period, period, getConstant( 'newton_constant' ), mass ] ),
                       getProduct( [ 4, pi, pi ] ) )

        velocity = divide( getProduct( [ 2, pi, getRoot( term, 3 ) ] ), period )

    return velocity.convert( 'meter/second' )
コード例 #3
0
ファイル: rpnPhysics.py プロジェクト: ConceptJunkie/rpn
def calculateBlackHoleMass( measurement ):
    validUnitTypes = [
        [ 'mass' ],
        [ 'length' ],
        [ 'acceleration' ],
        [ 'area' ],
        [ 'temperature' ],
        [ 'power' ],
        [ 'tidal_force' ],
        [ 'time' ],
    ]

    arguments = matchUnitTypes( [ measurement ], validUnitTypes )

    if not arguments:
        raise ValueError( 'black_hole_mass: invalid argument' )

    if 'mass' in arguments:
        return arguments[ 'mass' ].convert( 'kilogram' )
    elif 'length' in arguments:
        radius = arguments[ 'length' ]

        return divide( getProduct( [ getPower( getConstant( 'speed_of_light' ), 2 ), radius ] ),
                       getProduct( [ 2, getConstant( 'newton_constant' ) ] ) ).convert( 'kilogram' )
    elif 'acceleration' in arguments:
        gravity = arguments[ 'acceleration' ]

        return divide( getPower( getConstant( 'speed_of_light' ), 4 ),
                       getProduct( [ 4, getConstant( 'newton_constant' ), gravity ] ) ).convert( 'kilogram' )
    elif 'area' in arguments:
        area = arguments[ 'area' ].convert( 'meters^2' )

        return getRoot( divide( getProduct( [ getPower( getConstant( 'speed_of_light' ), 4 ), area ] ),
                                getProduct( [ 16, pi, getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 2 ).convert( 'kilogram' )
    elif 'temperature' in arguments:
        temperature = arguments[ 'temperature' ]

        return divide( getProduct( [ getConstant( 'reduced_planck_constant' ), getPower( getConstant( 'speed_of_light' ), 3 ) ] ),
                       getProduct( [ temperature, 8, getConstant( 'boltzmann_constant' ), pi, getConstant( 'newton_constant' ) ] ) ).convert( 'kilogram' )
    elif 'power' in arguments:
        luminosity = arguments[ 'power' ]

        return getRoot( divide( getProduct( [ getConstant( 'reduced_planck_constant' ), getPower( getConstant( 'speed_of_light' ), 6 ) ] ),
                                getProduct( [ luminosity.convert( 'kilogram*meter^2/second^3' ), 15360, pi,
                                     getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 2  ).convert( 'kilogram' )
    elif 'tidal_force' in arguments:
        tidal_force = arguments[ 'tidal_force' ]

        return getRoot( divide( getPower( getConstant( 'speed_of_light' ), 6 ),
                                getProduct( [ 4, tidal_force, getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 2 ).convert( 'kilogram' )
    elif 'time' in arguments:
        lifetime = arguments[ 'time' ]

        return getRoot( divide( getProduct( [ lifetime, getConstant( 'reduced_planck_constant' ), getPower( getConstant( 'speed_of_light' ), 4 ) ] ),
                                getProduct( [ 5120, pi, getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 3 ).convert( 'kilogram' )

    raise ValueError( 'invalid arguments to black hole operator' )
コード例 #4
0
ファイル: rpnPhysics.py プロジェクト: GaelicGrime/rpn
def calculateOrbitalRadiusOperator( measurement1, measurement2 ):
    '''
    To solve the radius of a circular orbit, we need Newton's gravitational
    constant and two of the following three items:

    G = Newton's gravitational constant

    m = planetary mass (i.e., mass of the thing being orbited)
    T = orbital period
    v = orbital velocity

    ---- radius in terms of period and mass
    r = cbrt( T^2*G*m/4*pi^2 )

    ---- radius in terms of velocity and mass
    r = G*m/v^2

    ---- radius in terms of velocity and period
    r = v*T/2*pi
    '''
    validUnitTypes = [
        [ 'mass', 'time' ],
        [ 'velocity', 'time' ],
        [ 'mass', 'velocity' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if not arguments:
        raise ValueError( '\'orbital_radius\' requires specific measurement types (see help)' )

    if 'mass' in arguments:
        mass = arguments[ 'mass' ]

        if 'time' in arguments:
            bPeriod = True
            period = arguments[ 'time' ]
        else:
            bPeriod = False
            velocity = arguments[ 'velocity' ]
    else:
        # period and velocity
        period = arguments[ 'time' ]
        velocity = arguments[ 'velocity' ]
        radius = divide( multiply( velocity, period ), fmul( 2, pi ) )
        return radius.convert( 'meter' )

    if bPeriod:
        # period and mass
        term = divide( getProduct( [ getPower( period, 2 ), getConstant( 'newton_constant' ), mass ] ),
                       fmul( 4, power( pi, 2 ) ) )
        radius = getRoot( term, 3 )
    else:
        # velocity and mass
        radius = divide( multiply( getConstant( 'newton_constant' ), mass ), getPower( velocity, 2 ) )

    return radius.convert( 'meter' )
コード例 #5
0
ファイル: rpnPhysics.py プロジェクト: GaelicGrime/rpn
def calculateOrbitalPeriodOperator( measurement1, measurement2 ):
    '''
    To solve the period of a circular orbit, we need Newton's gravitational
    constant and two of the following three items:

    G = Newton's gravitational constant

    m = planetary mass (i.e., mass of the thing being orbited)
    r = orbit radius (the distance from the center of mass)
    v = orbital velocity

    ---- period in terms of radius and mass
    T = 2*pi*sqrt( r^3/G*m )

    ---- period in terms of radius and velocity
    T = 2*pi*r/v

    ---- period in terms of mass and velocity
    T = 2*pi*G*m/v^3
    '''
    validUnitTypes = [
        [ 'mass', 'length' ],
        [ 'velocity', 'length' ],
        [ 'mass', 'velocity' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if not arguments:
        raise ValueError( '\'orbital_period\' requires specific measurement types (see help)' )

    if 'mass' in arguments:
        mass = arguments[ 'mass' ]

        if 'length' in arguments:
            bRadius = True
            radius = arguments[ 'length' ]
        else:
            bRadius = False
            velocity = arguments[ 'velocity' ]
    else:
        # radius and velocity
        radius = arguments[ 'length' ]
        velocity = arguments[ 'velocity' ]
        period = divide( getProduct( [ 2, pi, radius ] ), velocity )
        return period.convert( 'second' )

    if bRadius:
        # radius and mass
        term = divide( getPower( radius, 3 ), multiply( getConstant( 'newton_constant' ), mass ) )
        period = getProduct( [ 2, pi, getRoot( term, 2 ) ] )
    else:
        # velocity and mass
        period = divide( getProduct( [ 2, pi, getConstant( 'newton_constant' ), mass ] ),
                         getPower( velocity, 3 ) )

    return period.convert( 'second' )
コード例 #6
0
ファイル: rpnPhysics.py プロジェクト: ConceptJunkie/rpn
def calculateOrbitalPeriod( measurement1, measurement2 ):
    '''
    To solve the period of a circular orbit, we need Newton's gravitational
    constant and two of the following three items:

    G = Newton's gravitational constant

    m = planetary mass (i.e., mass of the thing being orbited)
    r = orbit radius (the distance from the center of mass)
    v = orbital velocity

    ---- period in terms of radius and mass
    T = 2*pi*sqrt( r^3/G*m )

    ---- period in terms of radius and velocity
    T = 2*pi*r/v

    ---- period in terms of mass and velocity
    T = 2*pi*G*m/v^3
    '''
    validUnitTypes = [
        [ 'mass', 'length' ],
        [ 'velocity', 'length' ],
        [ 'mass', 'velocity' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if not arguments:
        raise ValueError( '\'orbital_period\' requires specific measurement types (see help)' )

    if 'mass' in arguments:
        mass = arguments[ 'mass' ]

        if 'length' in arguments:
            bRadius = True
            radius = arguments[ 'length' ]
        else:
            bRadius = False
            velocity = arguments[ 'velocity' ]
    else:
        # radius and velocity
        radius = arguments[ 'length' ]
        velocity = arguments[ 'velocity' ]
        period = divide( getProduct( [ 2, pi, radius ] ), velocity )
        return period.convert( 'second' )

    if bRadius:
        # radius and mass
        term = divide( getPower( radius, 3 ), multiply( getConstant( 'newton_constant' ), mass ) )
        period = getProduct( [ 2, pi, getRoot( term, 2 ) ] )
    else:
        # velocity and mass
        period = divide( getProduct( [ 2, pi, getConstant( 'newton_constant' ), mass ] ),
                         getPower( velocity, 3 ) )

    return period.convert( 'second' )
コード例 #7
0
ファイル: rpnPhysics.py プロジェクト: ConceptJunkie/rpn
def calculateOrbitalRadius( measurement1, measurement2 ):
    '''
    To solve the radius of a circular orbit, we need Newton's gravitational
    constant and two of the following three items:

    G = Newton's gravitational constant

    m = planetary mass (i.e., mass of the thing being orbited)
    T = orbital period
    v = orbital velocity

    ---- radius in terms of period and mass
    r = cbrt( T^2*G*m/4*pi^2 )

    ---- radius in terms of velocity and mass
    r = G*m/v^2

    ---- radius in terms of velocity and period
    r = v*T/2*pi
    '''
    validUnitTypes = [
        [ 'mass', 'time' ],
        [ 'velocity', 'time' ],
        [ 'mass', 'velocity' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if not arguments:
        raise ValueError( '\'orbital_radius\' requires specific measurement types (see help)' )

    if 'mass' in arguments:
        mass = arguments[ 'mass' ]

        if 'time' in arguments:
            bPeriod = True
            period = arguments[ 'time' ]
        else:
            bPeriod = False
            velocity = arguments[ 'velocity' ]
    else:
        # period and velocity
        period = arguments[ 'time' ]
        velocity = arguments[ 'velocity' ]
        radius = divide( multiply( velocity, period ), fmul( 2, pi ) )
        return radius.convert( 'meter' )

    if bPeriod:
        # period and mass
        term = divide( getProduct( [ getPower( period, 2 ), getConstant( 'newton_constant' ), mass ] ),
                       fmul( 4, power( pi, 2 ) ) )
        radius = getRoot( term, 3 )
    else:
        # velocity and mass
        radius = divide( multiply( getConstant( 'newton_constant' ), mass ), getPower( velocity, 2 ) )

    return radius.convert( 'meter' )
コード例 #8
0
ファイル: rpnGeometry.py プロジェクト: ConceptJunkie/rpn
def getDodecahedronSurfaceArea( n ):
    if not isinstance( n, RPNMeasurement ):
        return getDodecahedronSurfaceArea( RPNMeasurement( real( n ), 'meter' ) )

    if n.getDimensions( ) != { 'length' : 1 }:
        raise ValueError( '\'dodecahedron_area\' argument must be a length' )

    area = getProduct( [ 3, getRoot( add( 25, fmul( 10, sqrt( 5 ) ) ), 2 ), getPower( n, 2 ) ] )
    return area.convert( 'meter^2' )
コード例 #9
0
ファイル: rpnPhysics.py プロジェクト: GaelicGrime/rpn
def calculateVelocityOperator( measurement1, measurement2 ):
    validUnitTypes = [
        [ 'length', 'time' ],
        [ 'acceleration', 'length' ],
        [ 'jerk', 'length' ],
        [ 'jounce', 'length' ],
        [ 'velocity', 'time' ],
        [ 'velocity', 'length' ],
        [ 'acceleration', 'time' ],
        [ 'jerk', 'time' ],
        [ 'jounce', 'time' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if 'velocity' in arguments:
        velocity = arguments[ 'velocity' ]
    elif 'length' in arguments:
        if 'time' in arguments:
            velocity = divide( arguments[ 'length' ], arguments[ 'time' ] )
        elif 'acceleration' in arguments:
            acceleration = arguments[ 'acceleration' ]
            time = getRoot( multiply( divide( arguments[ 'length' ], acceleration ), 2 ), 2 )
            velocity = multiply( acceleration, time )
        elif 'jerk' in arguments:
            jerk = arguments[ 'jerk' ]
            time = getRoot( multiply( divide( arguments[ 'length' ], jerk ), 6 ), 3 )
            velocity = getProduct( [ jerk, time, time, fdiv( 1, 2 ) ] )
        elif 'jounce' in arguments:
            jounce = arguments[ 'jounce' ]
            time = getRoot( multiply( divide( arguments[ 'length' ], jounce ), 24 ), 4 )
            velocity = getProduct( [ jounce, time, time, time, fdiv( 1, 6 ) ] )
    elif 'acceleration' in arguments:
        velocity = divide( multiply( arguments[ 'acceleration' ], arguments[ 'time' ] ), 2 )
    elif 'jerk' in arguments:
        velocity = divide( multiply( arguments[ 'jerk' ], getPower( arguments[ 'time' ], 2 ) ), 4 )
    elif 'jounce' in arguments:
        velocity = divide( multiply( arguments[ 'jounce' ], getPower( arguments[ 'time' ], 3 ) ), 8 )

    return velocity.convert( 'meter/second' )
コード例 #10
0
ファイル: rpnPhysics.py プロジェクト: ConceptJunkie/rpn
def calculateVelocity( measurement1, measurement2 ):
    validUnitTypes = [
        [ 'length', 'time' ],
        [ 'acceleration', 'length' ],
        [ 'jerk', 'length' ],
        [ 'jounce', 'length' ],
        [ 'velocity', 'time' ],
        [ 'velocity', 'length' ],
        [ 'acceleration', 'time' ],
        [ 'jerk', 'time' ],
        [ 'jounce', 'time' ],
    ]

    arguments = matchUnitTypes( [ measurement1, measurement2 ], validUnitTypes )

    if 'velocity' in arguments:
        velocity = arguments[ 'velocity' ]
    elif 'length' in arguments:
        if 'time' in arguments:
            velocity = divide( arguments[ 'length' ], arguments[ 'time' ] )
        elif 'acceleration' in arguments:
            acceleration = arguments[ 'acceleration' ]
            time = getRoot( multiply( divide( arguments[ 'length' ], acceleration ), 2 ), 2 )
            velocity = multiply( acceleration, time )
        elif 'jerk' in arguments:
            jerk = arguments[ 'jerk' ]
            time = getRoot( multiply( divide( arguments[ 'length' ], jerk ), 6 ), 3 )
            velocity = getProduct( [ jerk, time, time, fdiv( 1, 2 ) ] )
        elif 'jounce' in arguments:
            jounce = arguments[ 'jounce' ]
            time = getRoot( multiply( divide( arguments[ 'length' ], jounce ), 24 ), 4 )
            velocity = getProduct( [ jounce, time, time, time, fdiv( 1, 6 ) ] )
    elif 'acceleration' in arguments:
        velocity = divide( multiply( arguments[ 'acceleration' ], arguments[ 'time' ] ), 2 )
    elif 'jerk' in arguments:
        velocity = divide( multiply( arguments[ 'jerk' ], getPower( arguments[ 'time' ], 2 ) ), 4 )
    elif 'jounce' in arguments:
        velocity = divide( multiply( arguments[ 'jounce' ], getPower( arguments[ 'time' ], 3 ) ), 8 )

    return velocity.convert( 'meter/second' )
コード例 #11
0
ファイル: rpnGeometry.py プロジェクト: ConceptJunkie/rpn
def getConeSurfaceArea( r, h ):
    if not isinstance( r, RPNMeasurement ):
        return getConeSurfaceArea( RPNMeasurement( real( r ), 'meter' ), h )

    if r.getDimensions( ) != { 'length' : 1 }:
        raise ValueError( '\'cone_area\' argument 1 must be a length' )

    if not isinstance( h, RPNMeasurement ):
        return getConeSurfaceArea( r, RPNMeasurement( real( h ), 'meter' ) )

    if h.getDimensions( ) != { 'length' : 1 }:
        raise ValueError( '\'cone_area\' argument 2 must be a length' )

    hypotenuse = getRoot( add( getPower( r, 2 ), getPower( h, 2 ) ), 2 )

    return getProduct( [ pi, r, add( r, hypotenuse ) ] )
コード例 #12
0
ファイル: rpnGeometry.py プロジェクト: ConceptJunkie/rpn
def getTriangleArea( a, b, c ):
    if not isinstance( a, RPNMeasurement ):
        return getTriangleArea( RPNMeasurement( real( a ), 'meter' ), b, c )

    if a.getDimensions( ) != { 'length' : 1 }:
        raise ValueError( '\'triangle_area\' argument 1 must be a length' )

    if not isinstance( b, RPNMeasurement ):
        return getTriangleArea( a, RPNMeasurement( real( b ), 'meter' ), c )

    if b.getDimensions( ) != { 'length' : 1 }:
        raise ValueError( '\'triangle_area\' argument 2 must be a length' )

    if not isinstance( c, RPNMeasurement ):
        return getTriangleArea( a, b, RPNMeasurement( real( c ), 'meter' ) )

    if b.getDimensions( ) != { 'length' : 1 }:
        raise ValueError( '\'triangle_area\' argument 3 must be a length' )

    if add( a, b ).isNotLarger( c ) or add( b, c ).isNotLarger( a ) or add( a, c ).isNotLarger( b ):
        raise ValueError( 'invalid triangle, the sum of any two sides must be longer than the third side' )

    s = divide( getSum( [ a, b, c ] ), 2 )   # semi-perimeter
    return getRoot( getProduct( [ s, subtract( s, a ), subtract( s, b ), subtract( s, c ) ] ), 2 )
コード例 #13
0
ファイル: rpnPhysics.py プロジェクト: ConceptJunkie/rpn
def calculateEscapeVelocity( mass, radius ):
    mass.validateUnits( 'mass' )
    radius.validateUnits( 'length' )

    velocity = getRoot( getProduct( [ 2, getConstant( 'newton_constant' ), mass ] ).divide( radius ), 2 )
    return velocity.convert( 'meter/second' )
コード例 #14
0
ファイル: rpnPhysics.py プロジェクト: GaelicGrime/rpn
def calculateEscapeVelocityOperator( mass, radius ):
    mass.validateUnits( 'mass' )
    radius.validateUnits( 'length' )

    velocity = getRoot( getProduct( [ 2, getConstant( 'newton_constant' ), mass ] ).divide( radius ), 2 )
    return velocity.convert( 'meter/second' )
コード例 #15
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckLength( ):
    return getRoot( g.h_bar.multiply( g.G ).divide( getPower( g.c, 3 ) ), 2 )
コード例 #16
0
ファイル: rpnPhysics.py プロジェクト: GaelicGrime/rpn
def calculateHorizonDistanceOperator( altitude, radius ):
    altitude.validateUnits( 'length' )
    radius.validateUnits( 'length' )

    distance = getRoot( getProduct( [ 2, radius, altitude ] ), 2 )
    return distance.convert( 'meter' )
コード例 #17
0
def getPlanckAcceleration( ):
    return getRoot( getPower( g.c, 7 ).divide( g.h_bar.multiply( g.G ) ), 2 )
コード例 #18
0
ファイル: rpnGeometry.py プロジェクト: GaelicGrime/rpn
def getConeSurfaceAreaOperator(radius, height):
    hypotenuse = getRoot(add(getPower(radius, 2), getPower(height, 2)), 2)
    return getProduct([pi, radius, add(radius, hypotenuse)])
コード例 #19
0
def getPlanckVoltage( ):
    return getRoot( getProduct( [ 4, pi, g.e0, getPower( g.c, 6 ) ] ).divide( g.G ), 2 )
コード例 #20
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckCharge( ):
    return getConstant( 'electron_charge' ).divide( getRoot( getFineStructureConstant( ), 2 ) )
コード例 #21
0
def getPlanckTemperature( ):
    return getRoot( g.h_bar.multiply( getPower( g.c, 5 ) ).
                    divide( g.G.multiply( getPower( g.k, 2 ) ) ), 2 )
コード例 #22
0
def getPlanckMomentum( ):
    return getRoot( g.h_bar.multiply( getPower( g.c, 3 ) ).divide( g.G ), 2 )
コード例 #23
0
def getPlanckTime( ):
    return getRoot( g.h_bar.multiply( g.G ).divide( getPower( g.c, 5 ) ), 2 )
コード例 #24
0
def getPlanckLength( ):
    return getRoot( g.h_bar.multiply( g.G ).divide( getPower( g.c, 3 ) ), 2 )
コード例 #25
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckMass( ):
    return getRoot( g.h_bar.multiply( g.c ).divide( g.G ), 2 )
コード例 #26
0
ファイル: rpnPhysics.py プロジェクト: GaelicGrime/rpn
def calculateBlackHoleMass( measurement ):
    # pylint: disable=line-too-long
    validUnitTypes = [
        [ 'mass' ],
        [ 'length' ],
        [ 'acceleration' ],
        [ 'area' ],
        [ 'temperature' ],
        [ 'power' ],
        [ 'tidal_force' ],
        [ 'time' ],
    ]

    arguments = matchUnitTypes( [ measurement ], validUnitTypes )

    if not arguments:
        raise ValueError( 'black_hole_mass: invalid argument' )

    if 'mass' in arguments:
        return arguments[ 'mass' ].convert( 'kilogram' )

    if 'length' in arguments:
        radius = arguments[ 'length' ]

        return divide( getProduct( [ getPower( getConstant( 'speed_of_light' ), 2 ), radius ] ),
                       getProduct( [ 2, getConstant( 'newton_constant' ) ] ) ).convert( 'kilogram' )

    if 'acceleration' in arguments:
        gravity = arguments[ 'acceleration' ]

        return divide( getPower( getConstant( 'speed_of_light' ), 4 ),
                       getProduct( [ 4, getConstant( 'newton_constant' ), gravity ] ) ).convert( 'kilogram' )

    if 'area' in arguments:
        area = arguments[ 'area' ].convert( 'meters^2' )

        return getRoot( divide( getProduct( [ getPower( getConstant( 'speed_of_light' ), 4 ), area ] ),
                                getProduct( [ 16, pi, getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 2 ).convert( 'kilogram' )

    if 'temperature' in arguments:
        temperature = arguments[ 'temperature' ]

        return divide( getProduct( [ getConstant( 'reduced_planck_constant' ), getPower( getConstant( 'speed_of_light' ), 3 ) ] ),
                       getProduct( [ temperature, 8, getConstant( 'boltzmann_constant' ), pi, getConstant( 'newton_constant' ) ] ) ).convert( 'kilogram' )

    if 'power' in arguments:
        luminosity = arguments[ 'power' ]

        return getRoot( divide( getProduct( [ getConstant( 'reduced_planck_constant' ), getPower( getConstant( 'speed_of_light' ), 6 ) ] ),
                                getProduct( [ luminosity.convert( 'kilogram*meter^2/second^3' ), 15360, pi,
                                              getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 2  ).convert( 'kilogram' )

    if 'tidal_force' in arguments:
        tidalForce = arguments[ 'tidal_force' ]

        return getRoot( divide( getPower( getConstant( 'speed_of_light' ), 6 ),
                                getProduct( [ 4, tidalForce, getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 2 ).convert( 'kilogram' )

    if 'time' in arguments:
        lifetime = arguments[ 'time' ]

        return getRoot( divide( getProduct( [ lifetime, getConstant( 'reduced_planck_constant' ), getPower( getConstant( 'speed_of_light' ), 4 ) ] ),
                                getProduct( [ 5120, pi, getPower( getConstant( 'newton_constant' ), 2 ) ] ) ), 3 ).convert( 'kilogram' )

    raise ValueError( 'invalid arguments to black hole operator' )
コード例 #27
0
def getPlanckElectricalInductance( ):
    return getRoot( g.G.multiply( g.h_bar ).divide( getPower( g.c, 7 ).
                                                    multiply( getPower( getProduct( [ 4, pi, g.e0 ] ), 2 ) ) ),
                    2 ).convert( 'henry' )
コード例 #28
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckTemperature( ):
    return getRoot( g.h_bar.multiply( getPower( g.c, 5 ) ).
        divide( g.G.multiply( getPower( g.k, 2 ) ) ), 2 )
コード例 #29
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckTime( ):
    return getRoot( g.h_bar.multiply( g.G ).divide( getPower( g.c, 5 ) ), 2 )
コード例 #30
0
ファイル: rpnPhysics.py プロジェクト: ConceptJunkie/rpn
def calculateHorizonDistance( altitude, radius ):
    altitude.validateUnits( 'length' )
    radius.validateUnits( 'length' )

    distance = getRoot( getProduct( [ 2, radius, altitude ] ), 2 )
    return distance.convert( 'meter' )
コード例 #31
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckVolume( ):
    return getRoot( getPower( g.h_bar.multiply( g.G ), 3 ).divide( getPower( g.c, 9 ) ), 2 )
コード例 #32
0
def getPlanckMass( ):
    return getRoot( g.h_bar.multiply( g.c ).divide( g.G ), 2 )
コード例 #33
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckMomentum( ):
    return getRoot( g.h_bar.multiply( getPower( g.c, 3 ) ).divide( g.G ), 2 )
コード例 #34
0
def getPlanckCharge( ):
    return getConstant( 'electron_charge' ).divide( getRoot( getFineStructureConstant( ), 2 ) )
コード例 #35
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckEnergy( ):
    return getRoot( g.h_bar.multiply( getPower( g.c, 5 ) ).divide( g.G ), 2 ).convert( 'joule' )
コード例 #36
0
def getPlanckVolume( ):
    return getRoot( getPower( g.h_bar.multiply( g.G ), 3 ).divide( getPower( g.c, 9 ) ), 2 )
コード例 #37
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckAngularFrequency( ):
    return RPNMeasurement( getRoot( getPower( g.c, 5 ).divide( g.h_bar. multiply( g.G ) ), 2 ).value,
                           'radian/second' )
コード例 #38
0
def getPlanckEnergy( ):
    return getRoot( g.h_bar.multiply( getPower( g.c, 5 ) ).divide( g.G ), 2 ).convert( 'joule' )
コード例 #39
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckVoltage( ):
    return getRoot( getProduct( [ 4, pi, g.e0, getPower( g.c, 6 ) ] ).divide( g.G ), 2 )
コード例 #40
0
def getPlanckMagneticInductance( ):
    return getRoot( getPower( g.c, 5 ).divide( getProduct( [ g.h_bar,
                                                             getPower( g.G, 2 ), 4, pi, g.e0 ] ) ),
                    2 ).convert( 'tesla' )
コード例 #41
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckMagneticInductance( ):
    return getRoot( getPower( g.c, 5 ).divide( getProduct( [ g.h_bar, \
                                              getPower( g.G, 2 ), 4, pi, g.e0 ] ) ), 2 ).convert( 'tesla' )
コード例 #42
0
def getPlanckViscosity( ):
    return getRoot( getPower( g.c, 9 ).divide( getPower( g.G, 3 ).multiply( g.h_bar ) ), 2 ).convert( 'pascal*second' )
コード例 #43
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckElectricalInductance( ):
    return getRoot( g.G.multiply( g.h_bar ).divide( getPower( g.c, 7 ). \
                                     multiply( getPower( getProduct( [ 4, pi, g.e0 ] ), 2 ) ) ), 2 ).convert( 'henry' )
コード例 #44
0
ファイル: rpnGeometry.py プロジェクト: GaelicGrime/rpn
def getTriangleAreaOperator(a, b, c):
    s = divide(getSum([a, b, c]), 2)  # semi-perimeter
    return getRoot(
        getProduct([s, subtract(s, a),
                    subtract(s, b),
                    subtract(s, c)]), 2)
コード例 #45
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckViscosity( ):
    return getRoot( getPower( g.c, 9 ).divide( getPower( g.G, 3 ).multiply( g.h_bar ) ), 2 ).convert( 'pascal*second' )
コード例 #46
0
ファイル: rpnGeometry.py プロジェクト: GaelicGrime/rpn
def getDodecahedronSurfaceAreaOperator(n):
    area = getProduct(
        [3, getRoot(add(25, fmul(10, sqrt(5))), 2),
         getPower(n, 2)])
    return area.convert('meter^2')
コード例 #47
0
ファイル: rpnConstantUtils.py プロジェクト: ConceptJunkie/rpn
def getPlanckAcceleration( ):
    return getRoot( getPower( g.c, 7 ).divide( g.h_bar.multiply( g.G ) ), 2 )