11_pine_optimal_nonbranching¶
Pine - Optimal Simulation Configuration without Branching Simulation pine_weights i_27
Install the package from pip (skip this step if the package is already installed)
[ ]:
! pip install ligning
Import Code for Lignin Optimization
[1]:
# set ligning path (optional if installed via pip)
import sys, os
project_path = os.path.abspath(os.path.join(os.getcwd(), '..\..\..'))
sys.path.insert(0, project_path)
import ligning.optimization as opt
import ligning.characterization as ch
import ligning.utils as ut
Set the destination of simulation outputs. ResultsName sets the first level of storage, library_name specifies the folder within ‘demo_results’ and the trial_index is optional, specifying the test number. This allows data from multiple simulations to be stored, rather than overwriting past results, if no trial_index is given
[2]:
ResultsName='demo_results'
library_name = 'pine_nobranch'
trial_index=0
Set distribution of linkages This sets the expected frequency of each type of linkage between monomers. Setting to 0 will disable that linkage for the simulation. [‘4-O-5’, ‘alpha-O-4’, ‘beta-O-4’, ‘5-5’, ‘beta-5’, ‘beta-beta’, ‘beta-1’]
[3]:
linkage_distribution_input = [0, 0, 66, 0.05, 18, 16, 0]
Set monomer distributions This sets the expected frequency of each type of monomers. Setting to 0 will disable that monomer for the simulation. [‘H’, ‘G’, ‘S’]
[4]:
monomer_distribution_input = [0, 100, 0]
Setting for additional metrics in simulation output Verbose reports monomer additions to polymers. Additional_metrics reports population data such as branching coefficient in the simulation output.
[5]:
verbose = False
additional_metrics = True
Set branching propensity of polymers Likelihood of a monomer linking to 3 or more neighboring monomers.
[6]:
branching_propensity = 0
Set population metrics Determines the target monomer size for the simulation. [‘number average molecular weight’, ‘weight average molecular weight’]
[7]:
population_metrics = None
Additional setting for expectations the size of the polymer population, including the expected average size, maximum polymer size, and distribution of sizes of polymers.
[8]:
expected_size = 6
max_size = 100
# size distribution scaling factor
distribution_scaling = 0.1
# size in MW
size_in_MW = False
Metropolis Temperatures The temperature for the Metropolis Monte Carlo in monomer addition (Tmetro) and polymer addition (Tmetro_out).
[9]:
Tmetro = 10
Tmetro_out = 10
Simulation settings Maximum iterations for monomer addition to each polymer, polymer addition to the population, and ring addition to the population. N_population is the number of polymers in the population. Seed_init sets the random seed for the simulation.
[10]:
i_max = 1000
i_max_out = 1000
i_max_ring = 500
n_population = 100
seed_init = 1
(Optional) Set metric weights 13 metrics are available The first seven are linkage distributions: ‘4-O-5’, ‘alpha-O-4’, ‘beta-O-4’, ‘5-5’, ‘beta-5’, ‘beta-beta’, ‘beta-1’ The next three are monomer distributions: ‘H’, ‘G’, ‘S’ Then the branching coefficient Two optional, representing ‘number average molecular weight’ and ‘weight average molecular weight’, are not included for this simulation
[11]:
metrics_weights = [1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1]
Create and run the simulation
[12]:
sim = opt.Simulation(linkage_distribution_input=linkage_distribution_input,
monomer_distribution_input=monomer_distribution_input,
expected_size=expected_size,
max_size=max_size,
distribution_scaling=distribution_scaling,
Tmetro=Tmetro,
Tmetro_out=Tmetro_out,
seed_init=seed_init,
ResultsName=ResultsName,
library_name=library_name,
trial_index=trial_index,
n_population=n_population,
i_max=i_max,
i_max_out=i_max_out,
i_max_ring=i_max_ring,
additional_metrics=additional_metrics,
population_metrics=population_metrics,
size_in_MW=size_in_MW,
branching_propensity=branching_propensity,
metrics_weights = metrics_weights,
verbose=verbose)
sim.run()
Starting a new trial, No.0:
C:\Users\jake_\Documents\GitHub\LigninGraphs\ligning\polymer.py:662: UserWarning: Input linkage type is not supported
warnings.warn("Input linkage type is not supported")
Runtime for creating all polymers : 9.47 minutes
C:\Users\jake_\Documents\GitHub\LigninGraphs\ligning\characterization.py:616: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
numerical_metrics = list(population_data.mean().index)
C:\Users\jake_\Documents\GitHub\LigninGraphs\ligning\characterization.py:617: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
population_mean = np.array([population_data.mean()])
C:\Users\jake_\Documents\GitHub\LigninGraphs\ligning\characterization.py:618: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
population_std = np.array([population_data.std()])
Target values:
{ '4-O-5': 0.0,
'5-5': 0.0004997501249375313,
'G': 1.0,
'H': 0.0,
'S': 0.0,
'alpha-O-4': 0.0,
'beta-1': 0.0,
'beta-5': 0.17991004497751126,
'beta-O-4': 0.6596701649175413,
'beta-beta': 0.15992003998001,
'branching_coeff': 1.0}
Optimal simulated values:
{ '4-O-5': 0.0,
'5-5': 0.0017241379310344827,
'G': 1.0,
'H': 0.0,
'MW': 1211.698722772277,
'MW_weighted': 1365.4796976304629,
'S': 0.0,
'alpha-O-4': 0.0,
'beta-1': 0.0,
'beta-5': 0.17586206896551723,
'beta-O-4': 0.7120689655172414,
'beta-beta': 0.1103448275862069,
'branching_coeff': 0.0,
'monomer_count': 6.742574257425742}
Acceptance Rates
Monomer Acceptance: 0.021084137013634853
Polymer Acceptance: 0.9619047619047619
Runtime for analyzing the results : 0.04 minutes
Process population
[13]:
P_population = sim.P_population
population = ch.Population(P_population, name=library_name, ResultsName=ResultsName, TrialIndex=str(trial_index))
population.analyze()
C:\Users\jake_\Documents\GitHub\LigninGraphs\ligning\characterization.py:616: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
numerical_metrics = list(population_data.mean().index)
C:\Users\jake_\Documents\GitHub\LigninGraphs\ligning\characterization.py:617: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
population_mean = np.array([population_data.mean()])
C:\Users\jake_\Documents\GitHub\LigninGraphs\ligning\characterization.py:618: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
population_std = np.array([population_data.std()])