Skip to content

Chemical

Zachary-Ronayne edited this page Oct 30, 2020 · 4 revisions

Chemical

Currently, Chemicals act as real chemicals, but do not have chemical interactions set up.

To add a new element or compound, go to initTestChemProperties at the bottom of ChemProperties.js and add a new call to makeElement or makeCompound, following the parameters as described.

Model

Chemicals currently hold mass, temperature, concentration, matterState, and properties.

Concentration, temperature, and matterState are currently unused, but are set up for use.

Properties are an object which holds static information about chemicals, like molar mass. These can be created with an ElementProperties object and a corresponding atomic number, or ID for the case of a made up element.

getID

This should return the specific ID of the Chemical, which likely will be based on the equation. Currently, only 3 example Chemicals have IDs, though Chemicals can have any attributes.

Controller

The Controller, i.e. ChemicalController2D contains exactly one Chemical.

For information on idToFunc and funcToId, see ExperimentObject.

Combine

This method is where Chemicals interact with each other. Currently, it combines the two masses of a Chemical together, and mixes the colors based on the relative amount of mass in each chemical. For example, if 100 units of a pure red Chemical are combined with 10 units of a pure white Chemical, then the resulting Combined Chemical will be mostly red, but somewhat approaching pink. The resulting Chemical is stored in the Chemical of the Controller which called combine().