Multi-component recipe
calc_recipe
Works out the solid to weigh or stock to take for each component of a recipe made up to a final volume.
- Runs
- Built, not hosted
- Level
- Checked against a reference: exact rational arithmetic
What it is
Computes solid masses and liquid stock or volume-share volumes for a multi-component recipe made up to finalVolume. Diluent volume is returned only when every component comes from a liquid stock; otherwise it is withheld with the reason.
Field: Solutions. It is the same calculation as Drybench Calc, called by an AI assistant through the server.
What it does
You give
finalVolume(required): Target final solution volume.components(required): Recipe components (1 to 40); each gives target concentration or volumeShare (percent v/v).
Asked with
- finalVolume
- 500 mL
It answered (computed)
- finalVolume
- 0.5 L
- liquids
- 0.06 L
Computed by this tool when the page was built. The steps between are not recorded, so this is not a worked example. The reply carries more values than are shown here.
Limits
- For the diluent: the volumes of dilute aqueous stocks add.
- The formula weight typed is that of the form weighed, salt and hydrate included.
- Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.
It will not answer when
- The components array is empty (status refused).
- A component gives no valid amount: non-positive target, purity outside (0, 100] %, non-positive stock concentration, or missing formulaWeight where needed (status refused, partial lines carry withheld rules LINE_NEEDS_FORMULA_WEIGHT, LINE_NON_POSITIVE, LINE_INVALID_STOCK, LINE_INVALID_PURITY, LINE_NON_FINITE).
- The stock volumes together exceed the final volume (status refused).
- Withheld rule on result.diluent when any component is weighed as a solid.
Every input, with its units2 inputs
finalVolume(required): Target final solution volume.components(required): Recipe components (1 to 40); each gives target concentration or volumeShare (percent v/v).
Every refusal, with its code8 refusals
| Code | When |
|---|---|
NEEDS_COMPONENTS | The components array is empty (status refused). |
INVALID_COMPONENTS | A component gives no valid amount: non-positive target, purity outside (0, 100] %, non-positive stock concentration, or missing formulaWeight where needed (status refused, partial lines carry withheld rules LINE_NEEDS_FORMULA_WEIGHT, LINE_NON_POSITIVE, LINE_INVALID_STOCK, LINE_INVALID_PURITY, LINE_NON_FINITE). |
STOCKS_EXCEED_FINAL_VOLUME | The stock volumes together exceed the final volume (status refused). |
WEIGHED_SOLID | Withheld rule on result.diluent when any component is weighed as a solid. |
VOLUME_FRACTION | Withheld rule on result.diluent when any component specifies volumeShare. |
WEIGHED_SOLID_AND_VOLUME_FRACTION | Withheld rule on result.diluent when both weighed solids and volumeShare components appear. |
CONFLICTING_TARGET | A component carries both target and volumeShare, or volumeShare alongside formulaWeight/fromStock (invalid-input). |
UNKNOWN_ARGUMENT | A field the component does not take (invalid-input). |
The calculation
The method's equations, constants and worked example.
Equation 1
A component weighed as a solid: m = C·V·M/p for a molar target (stock-salt-purity@1.0.0), m = ρ·V/p for a mass-concentration target.
| Symbol | Meaning |
|---|---|
m | mass to weigh, g |
C | molar concentration wanted in the final solution, mol/L |
ρ | mass concentration wanted in the final solution, g/L |
V | final volume the recipe is made up to, L |
M | formula weight of the form weighed, as typed, g/mol |
p | purity as a mass fraction of the form weighed (1 when not given), 1 |
Equation 2
A component taken from a liquid stock: V1 = C2·V2/C1, both concentrations on one basis. Where the target is molar and the stock is by mass, V1 = C2·V2·M/ρ1
where the target is by mass and the stock molar, V1 = ρ2·V2/(C1·M).
| Symbol | Meaning |
|---|---|
V1 | volume of stock to take, L |
C1, ρ1 | the stock's molar or mass concentration, mol/L, g/L |
C2, ρ2 | the molar or mass concentration wanted, mol/L, g/L |
V2 | final volume, L |
Equation 3
A component wanted as a volume fraction: V1 = φ·V2.
| Symbol | Meaning |
|---|---|
φ | volume fraction of the final volume (0.1 for 10 percent v/v), 1 |
Equation 4
Diluent = V2 − ΣV1, given only when every line is taken from a liquid stock.
| Symbol | Meaning |
|---|---|
ΣV1 | sum of the stock volumes, L |
A definition, not a model: the equation states what the quantity means. A different convention gives a different number.
Worked example
Worked example: one case of recipe-table@2.1.0, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- finalVolume = 500 mL
- components[0].name = Solid A
- components[0].target = 50 mM
- components[0].formulaWeight = 120
- components[1].name = Solid B
- components[1].target = 2 g/L
- components[1].purityPercent = 98
- components[2].name = Stock C
- components[2].target = 150 mM
- components[2].fromStock = 5 M
- components[3].name = Liquid D
- components[3].volumePercent = 10
- components[4].name = Stock E
- components[4].target = 0.5 g/L
- components[4].fromStock = 100 g/L
- components[5].name = Stock F
- components[5].target = 1 mM
- components[5].formulaWeight = 200
- components[5].fromStock = 20 g/L
Steps
- solid-a: m = C·V·M/p = 3 g g, from component = weighed; 50 mM wanted; formula weight 120 g/mol; purity 100 percent, V2 = 0.5 L; gives Solid A.
- solid-b: m = ρ·V/p = 1.02040816 g g, from component = weighed; 2 g/L wanted; purity 98 percent, V2 = 0.5 L; gives Solid B.
- stock-c: V1 = C2·V2/C1 = 0.015 L L, from component = 150 mM wanted from a 5 M stock, V2 = 0.5 L; gives Stock C.
- liquid-d: V1 = φ·V2 = 0.05 L L, from component = 10 percent v/v, V2 = 0.5 L; gives Liquid D.
- stock-e: V1 = ρ2·V2/ρ1 = 0.0025 L L, from component = 0.5 g/L wanted from a 100 g/L stock, V2 = 0.5 L; gives Stock E.
- stock-f: V1 = C2·V2·M/ρ1 = 0.005 L L, from component = 1 mM wanted (formula weight 200 g/mol) from a 20 g/L stock, V2 = 0.5 L; gives Stock F.
- liquids: sum of the volumes taken = 0.0725 L L.
- diluent: given only when every line is taken from a liquid stock = not given: two lines are weighed solids and one is a volume fraction, so the recipe is made up to 0.5 L.
The working, as the case writes it:
m = C·V·M/p
m = ρ·V/p
V1 = C2·V2/C1
V1 = φ·V2
V1 = ρ2·V2/ρ1
V1 = C2·V2·M/ρ1.
Answer
Solid A = 3 g g
Solid B = 1.02040816 g g
Stock C = 0.015 L L
Liquid D = 0.05 L L
Stock E = 0.0025 L L
Stock F = 0.005 L L
Where these values came from: our own exact-arithmetic script and a hand-worked case; The definitions (see origin).
The build has not run this example through the tool.
Sources
No source is recorded for this tool's methods.
How it is checked
- Level
Checked against a reference.
- Checked against
Exact rational arithmetic (Python fractions) on 27 cases, 12 of them refused: each component's mass or volume and the diluent to nine significant figures; refusals, and the 9 recipes with a weighed or volume-fraction component that give no diluent volume, exact; 28 October 2026.
- Cases
27 on record; not printed here.
- Hostile inputs
Sent 56 malformed, extreme and misspelt calls. None broke it, and every call with an undeclared argument, or with text in place of a number or a true/false value, was declined with a reason.
Run 2026-11-12-2 of 12 November 2026, server 0.11.0.
- Same answer
Called twice and with its arguments in another order, it gave the same result; rewriting its quantities in other units changed no number (2 rewrites).
Run 2026-11-12-2 of 12 November 2026, server 0.11.0.
- Not checked
Non-additive mixing is not modelled: a recipe with a weighed solid or a volume fraction is made up to volume and no diluent is given, and for liquid stocks additivity is assumed. Whether a component dissolves at the amount given is not checked.
What was not checked, in fullfrom the method records
- Non-additive mixing is not modelled: a recipe with a weighed solid or a volume fraction is made up to volume and no diluent is given, and for liquid stocks additivity is assumed.
- Whether a component dissolves at the amount given is not checked.
- No published case set names recipe-table@2.1.0 by its exact key.
- The same file holds a second case, an all-liquid recipe with its diluent (hand-all-liquid-diluent).
- No case runs this method through the served tool on its production runtime.
What this project's records still lack1 thing
- A run of the worked example through the tool for recipe-table@2.1.0.
Cite a number from this toolthe cite line
Every reply carries a cite line naming the tool, the server version, each method with its version and level, and the receipt. Quote it with any number taken from the reply.
calc_recipe, server 1.0.0; recipe-table@2.1.0 (Checked against a reference); receipt e375a082674a/4d8db86d6da9; methods https://www.drybench.com/methods/calculators; page https://www.drybench.com/methods/tools/calc-recipe. Quote this line with any number taken from this reply.Changes to its methods0 changes
No change is logged for these method versions.