§
    OŠtj©  ã                  ó–   — d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ d
dlmZ  G d„ de¦  «        ZdS )zG
Unit system for physical quantities; include definition of constants.
é    )Úannotations)ÚAdd)Ú
DerivativeÚFunction)ÚMul)ÚPow)ÚS)Ú_QuantityMapper©ÚQuantityé   )Ú	Dimensionc                  óþ   ‡ — e Zd ZU dZi Zded<   ddddi fdˆ fd	„Zd
„ Zd„ Zddddi fdd„Z	d„ Z
ˆ fd„Zˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zedd„¦   «         Zd„ Zd„ Zdd„Zˆ xZS )Ú
UnitSystemzð
    UnitSystem represents a coherent set of units.

    A unit system is basically a dimension system with notions of scales. Many
    of the methods are defined in the same way.

    It is much better if all base units have a symbol.
    zdict[str, UnitSystem]Ú_unit_systems© Ú NÚderived_unitsúdict[Dimension, Quantity]c                ó6  •— | t           j        |<   || _        || _        || _        || _        t          t          |¦  «        t          |¦  «        z  ¦  «        | _        t          |¦  «        | _        || _	        t          ¦   «                              ¦   «          d S ©N)r   r   ÚnameÚdescrÚ_base_unitsÚ_dimension_systemÚtupleÚsetÚ_unitsÚ_derived_unitsÚsuperÚ__init__)ÚselfÚ
base_unitsÚunitsr   r   Údimension_systemr   Ú	__class__s          €ú\/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/physics/units/unitsystem.pyr!   zUnitSystem.__init__   s‚   ø€ à)-�
Ô  Ñ&àˆŒ	ØˆŒ
à%ˆÔØ!1ˆÔÝ�C 
™OœO­c°%©j¬jÑ8Ñ9Ô9ˆŒÝ  Ñ,Ô,ˆÔØ+ˆÔå‰Œ×ÒÑÔÐÐÐó    c                ót   — | j         dk    r| j         S dd                     d„ | j        D ¦   «         ¦  «        z  S )zš
        Return the name of the system.

        If it does not exist, then it makes a list of symbols (or names) of
        the base dimensions.
        r   zUnitSystem((%s))ú, c              3  ó4   K  — | ]}t          |¦  «        V — Œd S r   )Ústr)Ú.0Úds     r'   ú	<genexpr>z%UnitSystem.__str__.<locals>.<genexpr>7   s9   è è € ð 22ð 22Ø•�A‘”ð22ð 22ð 22ð 22ð 22ð 22r(   )r   Újoinr   ©r"   s    r'   Ú__str__zUnitSystem.__str__,   sS   € ð Œ9˜Š?ˆ?Ø”9Ðà%¨¯	ª	ð 22ð 22Ø $Ô 0ð22ñ 22ô 22ñ )2ô )2ñ 2ð 2r(   c                ó0   — dt          | j        ¦  «        z  S )Nz<UnitSystem: %s>)Úreprr   r1   s    r'   Ú__repr__zUnitSystem.__repr__:   s   € Ø!¥D¨Ô)9Ñ$:Ô$:Ñ:Ð:r(   c           	     ó˜   — | j         t          |¦  «        z   }| j        t          |¦  «        z   }t          |||||i | j        ¥|¥¦  «        S )a  Extend the current system into a new one.

        Take the base and normal units of the current system to merge
        them to the base and normal units given in argument.
        If not provided, name and description are overridden by empty strings.
        )r   r   r   r   r   )r"   Úbaser$   r   Údescriptionr%   r   s          r'   ÚextendzUnitSystem.extend=   sQ   € ð Ô¥%¨¡+¤+Ñ-ˆØ”�e E™lœlÑ*ˆå˜$  t¨[Ð:JÐLtÈtÔObÐLtÐfsÐLtÑuÔuÐur(   c                ó   — | j         S r   )r   r1   s    r'   Úget_dimension_systemzUnitSystem.get_dimension_systemJ   s   € ØÔ%Ð%r(   c                ó�   •— |                       ¦   «         j        }||v r||         S t          ¦   «                              |¦  «        S r   )r;   Ú_quantity_dimension_mapr    Úget_quantity_dimension)r"   ÚunitÚqdmr&   s      €r'   r>   z!UnitSystem.get_quantity_dimensionM   sB   ø€ Ø×'Ò'Ñ)Ô)ÔAˆØ�3ˆ;ˆ;Ø�t”9ÐÝ‰wŒw×-Ò-¨dÑ3Ô3Ð3r(   c                ó�   •— |                       ¦   «         j        }||v r||         S t          ¦   «                              |¦  «        S r   )r;   Ú_quantity_scale_factorsr    Úget_quantity_scale_factor)r"   r?   Úqsfmr&   s      €r'   rC   z$UnitSystem.get_quantity_scale_factorS   sB   ø€ Ø×(Ò(Ñ*Ô*ÔBˆØ�4ˆ<ˆ<Ø˜”:ÐÝ‰wŒw×0Ò0°Ñ6Ô6Ð6r(   c           	     ó  — t          | t          ¦  «        r| S | t          j        vrLt          d                     d                     t          t          j        ¦  «        ¦  «        ¦  «        ¦  «        ‚t          j        |          S )NzDUnit system is not supported. Currentlysupported unit systems are {}r*   )Ú
isinstancer   r   Ú
ValueErrorÚformatr0   Úsorted)Úunit_systems    r'   Úget_unit_systemzUnitSystem.get_unit_systemY   sx   € å�k¥:Ñ.Ô.ð 	ØÐà�jÔ6Ð6Ð6Ýð0ß06²Ø—I’I�f¥ZÔ%=Ñ>Ô>Ñ?Ô?ñ1ô 1ñô ð õ Ô'¨Ô4Ð4r(   c                 ó&   — t           j        d         S )NÚSI)r   r   r   r(   r'   Úget_default_unit_systemz"UnitSystem.get_default_unit_systemh   s   € åÔ'¨Ô-Ð-r(   c                ó*   — t          | j        ¦  «        S )zr
        Give the dimension of the system.

        That is return the number of units forming the basis.
        )Úlenr   r1   s    r'   ÚdimzUnitSystem.diml   s   € õ �4Ô#Ñ$Ô$Ð$r(   c                ó4   — |                       ¦   «         j        S )zI
        Check if the underlying dimension system is consistent.
        )r;   Úis_consistentr1   s    r'   rS   zUnitSystem.is_consistentu   s   € ð ×(Ò(Ñ*Ô*Ô8Ð8r(   Úreturnc                ó   — | j         S r   )r   r1   s    r'   r   zUnitSystem.derived_units}   s   € àÔ"Ð"r(   c                ó  ‡ — ddl m} t          |t          ¦  «        rt          ˆ fd„|j        D ¦   «         Ž S t          |t
          ¦  «        r"‰                      |j        ¦  «        |j        z  S t          |t          ¦  «        r ‰                      |j        d         ¦  «        S t          |t          ¦  «        rD‰                      |j        ¦  «        }|j        D ] \  }}|‰                      |¦  «        |z  z  }Œ!|S t          |t          ¦  «        rBˆ fd„|j        D ¦   «         }t          d„ |D ¦   «         ¦  «        rt          j        S  |j        |Ž S t          ||¦  «        r‰                      |¦  «        j        S t          j        S )Nr   r   c                ó:   •— g | ]}‰                      |¦  «        ‘ŒS r   ©Úget_dimensional_expr)r-   Úir"   s     €r'   ú
<listcomp>z3UnitSystem.get_dimensional_expr.<locals>.<listcomp>„   s'   ø€ ÐIÐIÐI¸!˜×2Ò2°1Ñ5Ô5ÐIÐIÐIr(   c                ó:   •— g | ]}‰                      |¦  «        ‘ŒS r   rX   ©r-   Úargr"   s     €r'   r[   z3UnitSystem.get_dimensional_expr.<locals>.<listcomp>�   s'   ø€ ÐHÐHÐH°s�D×-Ò-¨cÑ2Ô2ÐHÐHÐHr(   c              3  ó"   K  — | ]
}|d k    V — ŒdS )r   Nr   )r-   rZ   s     r'   r/   z2UnitSystem.get_dimensional_expr.<locals>.<genexpr>�   s&   è è € Ð(Ð(˜a�1˜’6Ð(Ð(Ð(Ð(Ð(Ð(r(   )Úsympy.physics.unitsr   rF   r   Úargsr   rY   r7   Úexpr   r   ÚexprÚvariable_countr   Úallr	   ÚOneÚfuncr>   r   )r"   rc   r   rQ   ÚindependentÚcountra   s   `      r'   rY   zUnitSystem.get_dimensional_expr�   sš  ø€ Ø0Ð0Ð0Ð0Ð0Ð0Ý�d�CÑ Ô ð 	:ÝÐIÐIÐIÐI¸t¼yÐIÑIÔIÐJÐJÝ˜�cÑ"Ô"ð 	:Ø×,Ò,¨T¬YÑ7Ô7¸4¼8ÑCÐCÝ˜�cÑ"Ô"ð 	:Ø×,Ò,¨T¬Y°q¬\Ñ:Ô:Ð:Ý˜�jÑ)Ô)ð 	:Ø×+Ò+¨D¬IÑ6Ô6ˆCØ&*Ô&9ð Eð EÑ"�˜UØ�t×0Ò0°Ñ=Ô=¸uÑDÑD��ØˆJÝ˜�hÑ'Ô'ð 	:ØHÐHÐHÐH¸d¼iÐHÑHÔHˆDÝÐ(Ð( 4Ð(Ñ(Ô(Ñ(Ô(ð Ý”u�Ø�4”9˜dÐ#Ð#Ý˜˜hÑ'Ô'ð 	:Ø×.Ò.¨tÑ4Ô4Ô9Ð9ÝŒuˆr(   c                óV  ‡ — ddl m} t          ||¦  «        r|j        |j        fS t          |t
          ¦  «        rAd}t          d¦  «        }|j        D ]$}‰                      |¦  «        \  }}||z  }||z  }Œ%||fS t          |t          ¦  «        rp‰                      |j
        ¦  «        \  }}‰                      |j        ¦  «        \  }	}
‰                      ¦   «                              |
¦  «        rd}
||	z  ||	|
z  z  fS t          |t          ¦  «        r¢‰                      |j        d         ¦  «        \  }}|j        dd…         D ]k}‰                      |¦  «        \  }}‰                      ¦   «                              ||¦  «        s$t!          d                     |||¦  «        ¦  «        ‚||z  }Œl||fS t          |t$          ¦  «        r\‰                      |j        d         ¦  «        \  }}|j        D ]-\  }}‰                      |¦  «        \  }}|||z  z  }|||z  z  }Œ.||fS t          |t(          ¦  «        r9ˆ fd„|j        D ¦   «         }ˆ fd„|D ¦   «         } |j        d„ |D ¦   «         Ž g|¢R S t          |t          ¦  «        rt,          j        |fS |t          d¦  «        fS )	zU
        Return tuple with scale factor expression and dimension expression.
        r   r   r   Nz,Dimension of "{}" is {}, but it should be {}c                ó:   •— g | ]}‰                      |¦  «        ‘ŒS r   )Ú_collect_factor_and_dimensionr]   s     €r'   r[   z<UnitSystem._collect_factor_and_dimension.<locals>.<listcomp>À   s'   ø€ ÐPÐPÐP¸s�4×5Ò5°cÑ:Ô:ÐPÐPÐPr(   c                ó˜   •— g | ]F}‰                      ¦   «                              |d          ¦  «        rt          d ¦  «        n|d          ‘ŒGS )r   )r;   Úis_dimensionlessr   )r-   r.   r"   s     €r'   r[   z<UnitSystem._collect_factor_and_dimension.<locals>.<listcomp>Á   sQ   ø€ ÐnÐnÐnÐef D×$=Ò$=Ñ$?Ô$?×$PÒ$PÐQRÐSTÔQUÑ$VÔ$VÐ`•I˜a‘L”L�LÐ\]Ð^_Ô\`ÐnÐnÐnr(   c              3  ó&   K  — | ]}|d          V — ŒdS )r   Nr   )r-   Úfs     r'   r/   z;UnitSystem._collect_factor_and_dimension.<locals>.<genexpr>Â   s&   è è € Ð2Ð2¨  !¤Ð2Ð2Ð2Ð2Ð2Ð2r(   )r`   r   rF   Úscale_factorÚ	dimensionr   r   ra   rl   r   r7   rb   r;   rn   r   Úequivalent_dimsrG   rH   r   rd   r   rg   r	   rf   )r"   rc   r   Úfactorrr   r^   Ú
arg_factorÚarg_dimrQ   Ú
exp_factorÚexp_dimÚaddendÚaddend_factorÚ
addend_dimrh   ri   ÚifactorÚidimÚfdsÚdimss   `                   r'   rl   z(UnitSystem._collect_factor_and_dimension—   s  ø€ ð 	1Ð0Ð0Ð0Ð0Ð0Ý�d˜HÑ%Ô%ð *	&ØÔ$ d¤nÐ4Ð4Ý˜�cÑ"Ô"ð (	&ØˆFÝ! !™œˆIØ”yð %ð %�Ø&*×&HÒ&HÈÑ&MÔ&MÑ#�
˜GØ˜*Ñ$�Ø˜WÑ$�	�	Ø˜9Ð$Ð$Ý˜�cÑ"Ô"ð  	&Ø×<Ò<¸T¼YÑGÔG‰KˆF�CØ"&×"DÒ"DÀTÄXÑ"NÔ"NÑˆJ˜Ø×(Ò(Ñ*Ô*×;Ò;¸GÑDÔDð Ø�Ø˜ZÑ'¨°¸gÑ1EÑ)FÐFÐFÝ˜�cÑ"Ô"ð 	&Ø×<Ò<¸T¼YÀq¼\ÑJÔJ‰KˆF�CØœ) A B Bœ-ð (ð (�à×6Ò6°vÑ>Ô>ñ *�˜zà×0Ò0Ñ2Ô2×BÒBÀ3È
ÑSÔSð 6Ý$ð.ß.4ªfØ" J°ñ/5ô /5ñ6ô 6ð 6ð ˜-Ñ'��Ø˜3�;ÐÝ˜�jÑ)Ô)ð 	&Ø×<Ò<¸T¼YÀq¼\ÑJÔJ‰KˆF�CØ&*Ô&9ð #ð #Ñ"�˜UØ $× BÒ BÀ;Ñ OÔ O‘�˜Ø˜' 5™.Ñ(�Ø�t˜U‘{Ñ"��Ø˜3�;ÐÝ˜�hÑ'Ô'ð 	&ØPÐPÐPÐPÀdÄiÐPÑPÔPˆCØnÐnÐnÐnÐjmÐnÑnÔnˆDØ�D”IÐ2Ð2¨cÐ2Ñ2Ô2Ð3Ð;°dÐ;Ð;Ð;Ý˜�iÑ(Ô(ð 	&Ý”5˜$�;Ðà� 1™œÐ%Ð%r(   úset[Quantity]c                óH   — t          t          d„ | j        ¦  «        ¦  «        S )zK
        Return the units of the system that do not have a prefix.
        c                ó"   — | j          o| j         S r   )Úis_prefixedÚis_physical_constant)Úus    r'   ú<lambda>z3UnitSystem.get_units_non_prefixed.<locals>.<lambda>Ì   s   € ¨¬Ð$5Ð$T¸aÔ>TÐ:T€ r(   )r   Úfilterr   r1   s    r'   Úget_units_non_prefixedz!UnitSystem.get_units_non_prefixedÈ   s$   € õ •6ÐTÐTÐVZÔVaÑbÔbÑcÔcÐcr(   )r   r   )rT   r   )rT   r€   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r!   r2   r5   r9   r;   r>   rC   ÚstaticmethodrK   rN   ÚpropertyrQ   rS   r   rY   rl   rˆ   Ú__classcell__)r&   s   @r'   r   r      sÈ  ø€ € € € € € ðð ð ,.€MÐ-Ð-Ð-Ñ-à)+°"¸BÐQUð  ACð ð ð ð ð ð ð ð2ð 2ð 2ð;ð ;ð ;ð "$¨"¸"Ètð  Að vð vð vð vð vð&ð &ð &ð4ð 4ð 4ð 4ð 4ð7ð 7ð 7ð 7ð 7ð ð5ð 5ñ „\ð5ð ð.ð .ñ „\ð.ð ð%ð %ñ „Xð%ð ð9ð 9ñ „Xð9ð ð#ð #ð #ñ „Xð#ðð ð ð,/&ð /&ð /&ðbdð dð dð dð dð dð dð dr(   r   N)rŒ   Ú
__future__r   Úsympy.core.addr   Úsympy.core.functionr   r   Úsympy.core.mulr   Úsympy.core.powerr   Úsympy.core.singletonr	   Úsympy.physics.units.dimensionsr
   Úsympy.physics.units.quantitiesr   Ú
dimensionsr   r   r   r(   r'   ú<module>rš      s  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø "Ð "Ð "Ð "Ð "Ð "Ø :Ð :Ð :Ð :Ð :Ð :Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3à !Ð !Ð !Ð !Ð !Ð !ð{dð {dð {dð {dð {d�ñ {dô {dð {dð {dð {dr(   