a
    7b}%                     @   s   d dl mZ d dlT d dlZd dlmZmZ d dlm	Z	 ddl
mZ d dlmZ ejZG d	d
 d
ejZG dd deZG dd deZdS )    )print_function)*N)platformexit)path   )thermo)abstractmethodc                       sT   e Zd ZdZ fddZedddZedd Zdd	d
Zdd Z	dd Z
  ZS )ljs_wca_base
    Interface to LJS-WCA
    c                    sT   t t|   t| j| dd| _t| j| dd| _t| j| dd| _dS );
        Initialize wca specific function pointers
        Z
eoslibinitZinit_ljs
lj_splinedZljs_wca_get_pure_paramsZljs_wca_set_pure_paramsN)	superr
   __init__getattrtpget_export_names_eoslibinit_init_ljss_ljs_wca_get_pure_paramss_ljs_wca_set_pure_paramsself	__class__ ]/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/pyctp/ljs_wca.pyr      s    zljs_wca_base.__init__Defaultc                 C   s   d S Nr   r   parameter_referencer   r   r   init"   s    zljs_wca_base.initc                 C   s   d S r   r   r   r   r   r   model_control&   s    zljs_wca_base.model_controlc                 C   sn   |    t|d}tt|}t|d}tt|}ttttg| j_d| j_| |||| d| _dS )a  Initialize Lennard-Jomes splined model based on Weeks-Chandler-Anderson perturbation theory

        Args:
            model (str, optional): Which model to use?. ("WCA", "UV", UF)
            parameter_reference (str, optional): Which parameters to use?. Defaults to "Default".
        asciiNr   )	activatec_char_pencode
c_len_typelenr   argtypesrestypeZnc)r   modelr   Zmodel_string_cZmodel_string_lenZref_string_cZref_string_lenr   r   r   
_base_init*   s"    zljs_wca_base._base_initc                 C   sT   |    td}td}ttttg| j_d| j_| t|t| |j|jfS )zGet particle size and well depth

        Returns:
            sigma (float): Particle diameter (m)
            eps_depth_divk (float): Well depth divided by Boltzmann constant (K)
                N)r#   c_doublePOINTERr   r(   r)   byrefvalue)r   sigma_ceps_depth_divk_cr   r   r   get_sigma_epsF   s    
zljs_wca_base.get_sigma_epsc                 C   sL   |    t|}t|}ttttg| j_d| j_| t|t| dS )zSet particle size and well depth

        Args:
            sigma (float): Particle diameter (m)
            eps_depth_divk (float): Well depth divided by Boltzmann constant (K)
        N)r#   r-   r.   r   r(   r)   r/   )r   sigmaZeps_depth_divkr1   r2   r   r   r   set_sigma_epsY   s    
zljs_wca_base.set_sigma_eps)r   )r   )__name__
__module____qualname____doc__r   r	   r    r!   r+   r3   r5   __classcell__r   r   r   r   r
      s   

r
   c                       s<   e Zd ZdZ fddZdddZddd	Zd
d Z  ZS )ljs_wcar   c                    s>   t t|   t| j| dd| _t| j| dd| _dS )r   r   Zljs_wca_model_controlZcalc_ljs_wca_ai_trN)r   r;   r   r   r   r   s_ljs_wca_model_controls_calc_ai_reduced_ljs_wcar   r   r   r   r   p   s    zljs_wca.__init__r   c                 C   s   | j d|d dS )Initialize Lennard-Jomes splined model based on Weeks-Chandler-Anderson perturbation theory

        Args:
            parameter_reference (str, optional): Which parameters to use?. Defaults to "Default".
        ZWCAr*   r   Nr+   r   r   r   r   r       s    zljs_wca.initTc              	   C   s   |    t|}t|}t|}	t|}
t|}t|}ttttttttttttg| j_d| j_| t|t|t|	t|
t|t| dS )aR  Model control. Enable/disable model terms.

        Args:
            enable_cavity (bool): Enable/disable use of cavity term. Defaults to True.
            enable_hs (bool): Enable/disable hard-sphere term. Defaults to True.
            enable_a1 (bool): Enable/disable use of a1 dispersion term. Defaults to True.
            enable_a2 (bool): Enable/disable use of a2 dispersion term. Defaults to True.
            enable_a3 (bool): Enable/disable use of a3 dispersion term. Defaults to True.
            enable_a4 (bool): Enable/disable use of a3 dispersion term. Defaults to True.
        N)r#   c_intr.   r<   r(   r)   r/   )r   Zenable_cavityZ	enable_hsZ	enable_a1Z	enable_a2Z	enable_a3Z	enable_a4Zenable_cavity_cZenable_hs_cZenable_a1_cZenable_a2_cZenable_a3_cZenable_a4_cr   r   r   r!      s,    
zljs_wca.model_controlc           	      C   s   t |}t |}tttt tt tt g| j_d| j_g }tdD ]D}t|d }t d}| t|t|t|t| ||j	 qD|S )a  Get perturbation terms.

        Args:
            T_star (float): Reduced temperature.
            rho_star (float): Reduced density.

        Returns:
            a1 (float): a1 dispersion term divided by epsilon.
            a2 (float): a2 dispersion term divided by epsilon squared.
            a3 (float): a3 dispersion term divided by epsilon cubed.
            a4 (float): a4 dispersion term divided by epsilon to the forth power .
        N   r   r,   )
r-   r.   rA   r=   r(   r)   ranger/   appendr0   )	r   ZT_starZrho_starZT_cZ
rho_star_cZaiii_cZai_cr   r   r   
get_pert_a   s&    
zljs_wca.get_pert_a)r   )TTTTTT)	r6   r7   r8   r9   r   r    r!   rG   r:   r   r   r   r   r;   l   s   
      
,r;   c                       s4   e Zd ZdZ fddZd
ddZddd	Z  ZS )ljs_uvz
    Interface to LJS-UV
    c                    s(   t t|   t| j| dd| _dS )z:
        Initialize UV specific function pointers
        r   Zljs_uv_model_controlN)r   rH   r   r   r   r   s_ljs_uv_model_controlr   r   r   r   r      s    zljs_uv.__init__r   c                 C   s   | j d|d dS )r>   ZUVr?   Nr@   r   r   r   r   r       s    zljs_uv.initFc                 C   s8   |    t|}ttg| j_d| j_| t| dS )zModel control. Enable/disable model terms.

        Args:
            use_temperature_dependent_u_fraction (bool): Enable/disable use of temperature dependent u-fraction.
        N)r#   rA   r.   rI   r(   r)   r/   )r   Z$use_temperature_dependent_u_fractionZ&use_temperature_dependent_u_fraction_cr   r   r   r!      s
    zljs_uv.model_control)r   )F)r6   r7   r8   r9   r   r    r!   r:   r   r   r   r   rH      s
   
 rH   )
__future__r   ctypesZnumpynpsysr   r   osr    r   abcr	   r&   Z
thermopackr
   r;   rH   r   r   r   r   <module>   s   Zr