<jupyter_start><jupyter_text>Minimization function<jupyter_code>from biorefineries import lipidcane2g as lc
import biosteam as bst
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from biosteam.utils import colors
from math import floor, ceil
from biosteam import plots
from biosteam.utils import CABBI_colors
from thermosteam.units_of_measure import format_units
from biosteam.plots.utils import style_axis, style_plot_limits, fill_plot, set_axes_labels

shadecolor = (*colors.neutral.RGBn, 0.30)
linecolor = (*colors.neutral_shade.RGBn, 0.85)
markercolor = (*colors.CABBI_blue_light.RGBn, 1)
edgecolor = (*colors.CABBI_black.RGBn, 1)

def tickmarks(data, accuracy=50, N_points=5):
    dmin = data.min()
    dmax = data.max()
    dmin = floor(dmin/accuracy) * accuracy
    dmax = ceil(dmax/accuracy) * accuracy
    step = (dmax - dmin) / (N_points - 1)
    if step == 0:
        return [0, 1]
    else:
        return [dmin + step * i for i in range(N_points)]

def create_inflection_plot(ax, name='1g', load=False, save=True):
    
    lipid_retention = np.linspace(0.5, 1.0, 10)
    if load:
        try:
            efficiency_inflection = np.load(f'lipid_extraction_efficiency_inflection{name}.npy')
        except:
            return create_inflection_plot(ax, name, False, save)
    else:
        lc.load(name)
        efficiency_inflection = np.array([
            lc.lipid_extraction_specification.solve_MFPP_inflection(i)
            for i in lipid_retention
        ])
        save and np.save(f'lipid_extraction_efficiency_inflection{name}', efficiency_inflection)
    
    mask = ~np.isnan(efficiency_inflection)
    ax.plot(100 * lipid_retention[mask], 100 * efficiency_inflection[mask], label=str(name))
        
fig, ax = plt.subplots()
create_inflection_plot(ax, 0, load=False)
create_inflection_plot(ax, 1, load=False)
create_inflection_plot(ax, 2, load=False)
create_inflection_plot(ax, 3, load=False)
plt.xlabel('Lipid retention [%]')
plt.ylabel('MFPP-Extraction efficiency inflection')
plt.legend()
plt.show()
lc.load(0)
lipid_retention = np.linspace(0.5, 1.0, 10)
efficiency_inflection = np.array([
    lc.lipid_extraction_specification.solve_MFPP_inflection(i)
    for i in lipid_retention
])

mask<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10514738231412231, 'fraction_numerical': 0.01759788825340959, 'mean_word_length': 4.168181818181818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '495293', 'license': 'MIT', 'n_tokens_mistral': 861, 'n_tokens_neox': 798, 'n_words': 172, 'path': 'BioSTEAM 2.x.x/biorefineries/oilcane/.ipynb_checkpoints/lipid_extraction_efficiency_inflection-checkpoint.ipynb', 'repo_name': 'yoelcortes/Bioindustrial-Complex', 'size': '2273'}