"""
This script calculates the physical properties of Brown Carbon (BrC) aerosols.

The script defines constants for hygroscopic growth based on established research
and provides functions to calculate physical properties for a range of aerosol types.
It allows for customization of properties for specific aerosol categories.

"""

import numpy as np

# Constants for SULFATE Hygroscopic Growth
# Fitzgerald [1975]; Haywood and Ramaswamy [1998]
SAT = np.array([0.80, 0.90, 0.95, 0.99])
F99 = 0.0155*(SAT[3] - 0.97)/(1.02 - SAT[3]**1.4)
PHI = np.array([1.058, 1.058, 1.058, 1.058-F99])
ALF = 1.2*np.exp(0.066*SAT/(PHI - SAT))
BET = np.exp(0.00077*SAT/(1.009 - SAT))
A80, A90, A95, A99 = ALF[0], ALF[1], ALF[2], ALF[3]
B80, B90, B95, B99 = BET[0], BET[1], BET[2], BET[3]

# Additional Constants
A30 = 1.0
m = (A80 - A30)/(0.80 - 0.30)
A50 = A30 + m*(0.50 - 0.30)
A70 = A30 + m*(0.70 - 0.30)
B30, B50, B70 = 1.0, 1.0, 1.0

def physical_properties_single(ri_brc):
    """
    Calculate the physical properties of Brc for a single aerosol type.

    Parameters:
    ri_brc (float): The real part of the refractive index of BrC.

    Returns:
    dict: A dictionary containing the physical properties of BrC.
    """
    phys = {
                # rgeo, sdev, rmin, rmax, real, imag, dens, alfa[0%:99%], beta[0%:99%]
                'WATE':[1.336, 1.0e-08],
                'BRC':[0.0212, 2.200, 0.005, 20.00, 1.501, ri_brc, 1.800, [1.0 for h in np.arange(7)],  [1.0 for h in np.arange(7)]] #phobic
        }
    return phys

def physical_properties_multi(ri_brc_strong, ri_brc_bleached):
    """
    Calculate the physical properties of BrC for multiple aerosol types.

    Parameters:
    ri_brc_strong (float): The real part of the refractive index of strong BrC.
    ri_brc_bleached (float): The real part of the refractive index of bleached BrC.

    Returns:
    dict: A dictionary containing the physical properties of BrC.
    """
    phys = {
                # rgeo, sdev, rmin, rmax, real, imag, dens, alfa[0%:99%], beta[0%:99%]
                'WATE':[1.336, 1.0e-08],
                'POABRC':[0.0212, 2.200, 0.005, 20.00, 1.501, ri_brc_strong, 1.800, [1.0 for h in np.arange(7)],  [1.0 for h in np.arange(7)]],
                'SOABRC':[0.0212, 2.200, 0.005, 20.00, 1.486, ri_brc_bleached, 1.800, [1.0,1.2,1.4,1.5,1.6,1.8,2.2], [1.0 for h in np.arange(7)]]
        }
    return phys
    
def physical_properties():
    """
    Calculate the physical properties of Brc for a single aerosol type.

    Parameters:
    ri_brc (float): The real part of the refractive index of BrC.

    Returns:
    dict: A dictionary containing the physical properties of BrC.
    """
    phys = {
        "WATE":[1.336, 1.0e-08],
        'BCPHOB':[0.0118, 2.000, 0.005, 20.00, 1.850, 7.1e-01, 1.000, [1.0 for h in np.arange(7)],  [1.0 for h in np.arange(7)]], #phob
        'BCPHIL':[0.0118, 2.000, 0.005, 20.00, 1.850, 7.1e-01, 1.000, [1.0,1.0,1.0,1.2,1.4,1.5,1.9], [1.0 for h in np.arange(7)]], #philic
        'POA':[0.0212, 2.200, 0.005, 20.00, 1.501, 5.7e-3, 1.800, [1.0 for h in np.arange(7)],  [1.0 for h in np.arange(7)]], #phob
        'OPOA':[0.0212, 2.200, 0.005, 20.00, 1.501, 1.0e-04, 1.800, [1.0,1.2,1.4,1.5,1.6,1.8,2.2], [1.0 for h in np.arange(7)]], #philic
        'SOA':[0.0212, 2.200, 0.005, 20.00, 1.486, 2.5e-05, 1.800, [1.0,1.2,1.4,1.5,1.6,1.8,2.2], [1.0 for h in np.arange(7)]],
    }
    return phys