chemistrylab.util package

chemistrylab.util.Visualization module

chemistrylab.util.Visualization.Visualizer(char_bench)[source]
chemistrylab.util.Visualization.fill_line(arr, x1, y1, x2, y2, lw)[source]
class chemistrylab.util.Visualization.matplotVisualizer(char_bench)[source]

Bases: object

static display_vessels(vessels: Tuple[Vessel], observation_list: Tuple[str])[source]
get_rgb(vessels: Tuple[Vessel])[source]
legend_update_delay = 1
render_PVT(vessel: Vessel, ax, first=False, prev=None)[source]
render_layers(vessel: Vessel, ax, first=False, prev=None)[source]
render_spectra(vessel: Vessel, ax, first=False, prev=None)[source]
render_target(vessel: Vessel, ax, first=False, prev=None)[source]
class chemistrylab.util.Visualization.numbaVisualizer(char_bench)[source]

Bases: object

get_rgb(vessels: Tuple[Vessel])[source]
render_PVT(vessel: Vessel)[source]
render_layers(vessel: Vessel)[source]
render_spectra(vessel: Vessel)[source]
render_target(target)[source]
class chemistrylab.util.Visualization.pygameVisualizer(char_bench)[source]

Bases: object

Class to visualize the chemistry benches.

The dictionary viz gives a list of observations the class can visualize. These should correspond to observations which come from the characterization bench.

Call get_rgb(vessels) to get an rgb image of your vessel observations (which visualize all observations set in the characterization bench)

The resultant image is tiled such that every row has one type of observation, and every column contains all observations for a single vessel.

get_rgb(vessels: Tuple[Vessel])[source]

Create an rgb image corresponding to the observations of each vessel.

render_PVT(vessel: Vessel, x: int, y: int)[source]

Method to create a bar graph of the pressure,volume, and temperature of a vessel

Parameters:
  • vessel (Vessel) – Vessel we want pvt info from.

  • x (int) – Position of the top left corner of this image tile

  • y (int) – Position of the top right corner of ths image tile

render_layers(vessel: Vessel, x: int, y: int)[source]

Method to visualize the layer information of a vessel.

Parameters:
  • vessel (Vessel) – The vessel inputted for layer analysis.

  • x (int) – Position of the top left corner of this image tile

  • y (int) – Position of the top right corner of ths image tile

render_spectra(vessel: Vessel, x: int, y: int)[source]

Method to visualize the spectral information of a vessel.

Parameters:
  • vessel (Vessel) – The vessel inputted for spectroscopic analysis.

  • x (int) – Position of the top left corner of this image tile

  • y (int) – Position of the top right corner of ths image tile

render_target(vessel: Vessel, x: int, y: int)[source]

Method to display the benches target.

Parameters:
  • vessel (Vessel) – A vessel

  • x (int) – The target will only be rendered if x=0

  • y (int) – Position of the top right corner of ths image tile

chemistrylab.util.Visualization.set_backend(backend: str)[source]
chemistrylab.util.Visualization.to_rgb(x)[source]

Converts a 4-channel rgba image into a 3-channel rgb image

chemistrylab.util.Visualization.use_mpl_dark(size=2)[source]
chemistrylab.util.Visualization.use_mpl_light(size=2)[source]

chemistrylab.util.reward module

This module provides a default set of reward functions.

class chemistrylab.util.reward.RewardGenerator(use_purity, exclude_solvents, include_dissolved, exclude_mat=None)[source]

Bases: object

RewardGenerator class generates rewards for a given set of vessels and desired materials.

Parameters:
  • use_purity (bool) – True if reward is based on purity, False if reward is based on the amount of desired material.

  • exclude_solvents (bool) – True if solvents should be excluded from the total amount of materials for purity calculations.

  • include_dissolved (bool) – True if reward should include dissolved material components in the vessels as the desired material.

  • exclude_mat (str, optional) – A string representing a material which gives a negative reward.

This class returns callable objects, which serve as reward functions

__call__(vessels: Tuple[Vessel], desired_material: str, exclude_material: str | None = None)[source]

Assign a reward to a set of vessels based off of what is desired/undesired

Parameters:
  • vessels (Tuple[Vessel]) – A list of Vessel objects.

  • desired_material (str) – A string representing the desired material for which the reward should be calculated.

  • exclude_material (Optional[str]) – Currently unused

Returns:

A floating point number representing the calculated reward.

Return type:

float

chemistrylab.util.reward.get_dissolved_amounts(vessel: Vessel, desired_material: str)[source]
Returns:

  • The amount material that could be produced if you removed the solvent. This is the minimum of (quantity/stoich_coeff) for each dissolved component

  • The amount of mols of solutes to subtract from the total material amount

Return type:

Tuple[float,float]

Module contents