smipoly.smip.polg module

polymer generator from classfied monomers.

smipoly.smip.polg.biplym(df, targ=None, dsp_rsl=None)

Generates polymers based on the input DataFrame and specified target polymer classes.

Parameters:
  • df (pd.DataFrame) – Input DataFrame containing monomer information. Must include a column named ‘smip_cand_mons’.

  • targ (list, optional) – List of targetted polymer classes to generate. Defaults to [‘all’, ] to include all available classes. Use [‘exc_ole’] to exclude polyolefins.

  • dsp_rsl (bool, optional) – Whether to display the results summary. Defaults to False.

Returns:

A DataFrame containing the generated polymers with the following columns:

  • ’mon1’: First monomer.

  • ’mon2’: Second monomer (if applicable).

  • ’polym’: Generated polymer.

  • ’polymer_class’: Class of the polymer.

  • ’Ps_rxnL’: Reaction key for the polymerization.

Return type:

pd.DataFrame

Notes

  • The function filters and processes the input DataFrame to identify valid monomers.

  • Polymers are generated based on predefined polymerization rules and target classes.

  • Duplicate polymerization reactions are removed, and the resulting DataFrame is adjusted.

  • If dsp_rsl is True, the function prints the number of polymerization reactions and generated polymers.

Raises:

ValueError – If an invalid polymer class is specified in targ.

smipoly.smip.polg.ole_copolym(df, targ=None, ncomp=None, dsp_rsl=None, drop_dupl=None)

Generates a DataFrame of copolymers based on the provided olefin classes and parameters.

Parameters:
  • df (pd.DataFrame) – Input DataFrame containing olefin classification and candidate monomers.

  • targ (list, optional) – List of target olefin classes. Must be provided as a list. Defaults to None.

  • ncomp (int, optional) – Number of components for copolymerization. Defaults to 1.

  • dsp_rsl (bool, optional) – If True, displays the number of generated copolymers. Defaults to False.

  • drop_dupl (bool, optional) – If True, drops duplicate copolymers from the resulting DataFrame. Defaults to True.

Returns:

A DataFrame containing the generated copolymers with columns:

  • ’mon1’: First monomer (if applicable).

  • ’mon2’: Second monomer (if applicable).

  • ’polym’: Polymer structure.

  • ’polymer_class’: Polymer classification.

  • ’Ps_rxnL’: Reaction conditions or initiators.

  • ’reactset’: Reactant set.

Return type:

pd.DataFrame

Raises:
  • ValueError – If targ is not provided or is not a list.

  • ValueError – If targ contains invalid olefin classes.

  • ValueError – If ncomp is less than the number of components in targ.

  • ValueError – If incompatible olefin classes are used together (e.g., ROMP with other classes).

Todo

  • Add procedure to removing some remaining duplicates in ROMP(H).

  • Add cationic polymerization via non-classical cations.

Notes

  • Valid olefin classes are displayed when the function is called without valid targ.

  • Special handling is applied for ROMP, ROMPH, and COC classes.

  • The function may take longer to execute if the input DataFrame is large and drop_dupl is True.