'''
Created on 26-May-2021

@author: bthakur
'''
from sympy.physics.units import (
    Quantity, G)

from sympy.physics.units.systems import SI
from sympy.physics.units.systems.si import dimsys_SI
from sympy.physics import units

class PhysicalQuantity(Quantity):
    
    #default_constant = _default_constant()
    #mass = _mass()
    #length = _length()
    #force = _force()

    @classmethod
    def _dimensionless(cls, name, abbrev = None, scale_factor = 1):
        _dl = PhysicalQuantity(name, abbrev = abbrev)
        _dl.set_quantity_dimension(units.dimensions.Dimension(1))
        _dl.set_quantity_scale_factor(scale_factor)
        return _dl       
        pass
    
    @classmethod
    def _default_constant(cls, name = 'k', abbrev = None, scale_factor = 1):
        _k = PhysicalQuantity(name, abbrev = abbrev)
        _k.set_quantity_dimension(units.dimensions.Dimension(1))
        _k.set_quantity_scale_factor(scale_factor)
        return _k       
        pass
    
    @classmethod
    def _mass(cls, name = 'mass', abbrev = 'm', scale_factor = units.kilogram):
        _m1 = PhysicalQuantity(name, abbrev = abbrev)
        _m1.set_quantity_dimension(units.mass)
        _m1.set_quantity_scale_factor(scale_factor)
        return _m1       
        pass
    
    @classmethod
    def _time(cls, name = 'time', abbrev = 't', scale_factor = units.second):
        _t = PhysicalQuantity(name, abbrev = abbrev)
        _t.set_quantity_dimension(units.mass)
        _t.set_quantity_scale_factor(scale_factor)
        return _t       
        pass
    
    @classmethod
    def _r(cls, name = 'distance', abbrev = 'r', scale_factor = units.meter):
        _r = PhysicalQuantity(name, abbrev = abbrev)
        _r.set_quantity_dimension(units.length)
        _r.set_quantity_scale_factor(scale_factor)
        return _r       
        pass
    
    @classmethod
    def _velocity(cls, name = 'velocity', abbrev = 'v', 
                  scale_factor = units.meter/units.second):
        _v = PhysicalQuantity(name, abbrev = abbrev)
        _v.set_quantity_dimension(units.length)
        _v.set_quantity_scale_factor(scale_factor)
        return _v       
        pass
    
    @classmethod
    def _force(cls, name = 'force', abbrev = 'F', scale_factor = units.newton):
        _f1 = PhysicalQuantity(name, abbrev = abbrev)
        _f1.set_quantity_dimension(units.force)
        _f1.set_quantity_scale_factor(scale_factor)
        return _f1       
        pass
    
    @classmethod
    def _pressure(cls, name = 'pressure', abbrev = 'P', scale_factor = units.pascal):
        _f1 = PhysicalQuantity(name, abbrev = abbrev)
        _f1.set_quantity_dimension(units.force)
        _f1.set_quantity_scale_factor(scale_factor)
        return _f1       
        pass
    
    @classmethod
    def _volume(cls, name = 'volume', abbrev = 'V', scale_factor = units.meter ** 3):
        _f1 = PhysicalQuantity(name, abbrev = abbrev)
        _f1.set_quantity_dimension(units.force)
        _f1.set_quantity_scale_factor(scale_factor)
        return _f1       
        pass

    @classmethod
    def _mole(cls, name = 'mole', abbrev = 'n', scale_factor = units.mole):
        _f1 = PhysicalQuantity(name, abbrev = abbrev)
        _f1.set_quantity_dimension(units.force)
        _f1.set_quantity_scale_factor(scale_factor)
        return _f1       
        pass
    
    @classmethod
    def _temperature(cls, name = 'temperature', abbrev = 'T', scale_factor = units.kelvin):
        _f1 = PhysicalQuantity(name, abbrev = abbrev)
        _f1.set_quantity_dimension(units.force)
        _f1.set_quantity_scale_factor(scale_factor)
        return _f1       
        pass
    
    @classmethod
    def _ideal_gas_constant(cls, name = 'ideal gas constant', abbrev = 'R', 
                            scale_factor = units.R):
        _f1 = PhysicalQuantity(name, abbrev = abbrev)
        _f1.set_quantity_dimension(units.force)
        _f1.set_quantity_scale_factor(scale_factor)
        return _f1       
        pass
    
    
    def __init__(self, name,
                #custom inputs
                abbrev=None, dimension=None, scale_factor=None,
                latex_repr=None, pretty_unicode_repr=None,
                pretty_ascii_repr=None, mathml_presentation_repr=None,
                **assumptions):
        super().__init__()
        pass
    
    def set_quantity_dimension(self, dimension):
        SI.set_quantity_dimension(self, dimension)
        pass
    
    def set_quantity_scale_factor(self, scale_factor):
        SI.set_quantity_scale_factor(self, scale_factor)
        pass
    
    def get_dimensional_dependencies(self):
        return dimsys_SI.get_dimensional_dependencies(self)
        pass


    pass