a
    7b3                     @   sl   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dS )    )print_function)*N)platformexit)path   )thermo)cubicc                       s:   e Zd ZdZ fddZddd	Zd
d Zdd Z  ZS )cpaz3
    Interface to cubic plus association model
    c                    sT   t t|   t| j| dd| _t| j| dd| _t| j| dd| _dS )z=
        Initialize cubic specific function pointers
        Z
eoslibinitZinit_cpaZsaft_interfaceZcpa_get_kijZcpa_set_kijN)	superr
   __init__getattrtpZget_export_nameeoslibinit_init_cpa	s_get_kij	s_set_kij)self	__class__ Y/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/pyctp/cpa.pyr      s    zcpa.__init__SRKvdWClassicDefaultc                 C   s   |    t|d}tt|}t|d}tt|}	t|d}
tt|}t|d}tt|}t|d}tt|}ttttttttttg
| j_d| j_| ||||
||||	||
 tt|	dt|	d| _
dS )a  Initialize cubic plus association model in thermopack

        Args:
            comps (str): Comma separated list of component names
            eos (str, optional): Cubic equation of state. Defaults to "SRK".
            mixing (str, optional): Mixture model. Defaults to "vdW".
            alpha (str, optional): Alpha model. Defaults to "Classic".
            parameter_reference (str, optional): Which parameters to use?. Defaults to "Default".
        asciiN ,)activatec_char_pencode
c_len_typelenr   argtypesrestypemaxsplitZnc)r   compsZeosZmixingalphaZparameter_referenceZeos_cZeos_lenZmixing_cZ
mixing_lenZalpha_cZ	alpha_lenZcomp_string_cZcomp_string_lenZref_string_cZref_string_lenr   r   r   init'   sF    
zcpa.initc                 C   sf   |    t|}t|}td d}ttttttg| j_d| j_| t|t|| t	|S )zGet attractive energy interaction parameter

        Args:
            c1 (int): Component one
            c2 (int): Component two

        Returns:
            kij (array_like): i-j interaction parameter (2 parameters)
           g        N)
r   c_intc_doublePOINTERr   r#   r$   byrefnparray)r   c1c2c1_cc2_ckij_cr   r   r   get_kijW   s    

zcpa.get_kijc                 C   s`   |    t|}t|}td | }ttttttg| j_d| j_| t|t|| dS )zSet attractive energy interaction parameter

        Args:
            c1 (int): Component one
            c2 (int): Component two
            kij (array_like): i-j interaction parameter (2 parameters)
        r*   N)r   r+   r,   r-   r   r#   r$   r.   )r   r1   r2   Zkijr3   r4   r5   r   r   r   set_kijq   s    
zcpa.set_kij)r   r   r   r   )	__name__
__module____qualname____doc__r   r)   r6   r7   __classcell__r   r   r   r   r
      s     
0r
   )
__future__r   ctypesZnumpyr/   sysr   r   osr    r   r	   r!   r
   r   r   r   r   <module>   s   