B
    }N€_ë  ã               @   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
        Ú
eoslibinitZinit_cpaZsaft_interfaceZcpa_get_kijZcpa_set_kijN)	Úsuperr
   Ú__init__ÚgetattrÚtpÚget_export_nameÚeoslibinit_init_cpaÚ	s_get_kijÚ	s_set_kij)Úself)Ú	__class__© ú../pycThermopack/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ú ú,)
Úc_char_pÚencodeÚ
c_len_typeÚlenr   ÚargtypesÚrestypeÚmaxÚsplitÚnc)r   ÚcompsÚeosÚmixingÚalphaÚparameter_referenceÚeos_cÚeos_lenÚmixing_cÚ
mixing_lenÚalpha_cÚ	alpha_lenÚcomp_string_cÚcomp_string_lenÚref_string_cÚref_string_lenr   r   r   Úinit'   s@    
zcpa.initc             C   s^   t |ƒ}t |ƒ}td dƒ}tt ƒtt ƒttƒg| j_d| j_|  t|ƒt|ƒ|¡ t |¡S )zäGet 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)	Úc_intÚc_doubleÚPOINTERr   r#   r$   ÚbyrefÚnpÚarray)r   Úc1Úc2Úc1_cÚc2_cÚkij_cr   r   r   Úget_kijV   s    

zcpa.get_kijc             C   sX   t |ƒ}t |ƒ}td |Ž }tt ƒtt ƒttƒg| j_d| j_|  t|ƒt|ƒ|¡ dS )zÒSet attractive energy interaction parameter

        Args:
            c1 (int): Component one
            c2 (int): Component two
            kij (array_like): i-j interaction parameter (2 parameters)
        r8   N)r9   r:   r;   r   r#   r$   r<   )r   r?   r@   ÚkijrA   rB   rC   r   r   r   Úset_kijo   s    
zcpa.set_kij)r   r   r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r7   rD   rF   Ú__classcell__r   r   )r   r   r
      s    
.r
   )Ú
__future__r   ÚctypesÚnumpyr=   Úsysr   r   Úosr   Ú r   r	   r!   r
   r   r   r   r   Ú<module>   s   