How can I create a matrix that represents all possible "recipes" of 3 chemical components? (i.e., the 3 chemical components must be positive and sum to 100 wt%)

3 views (last 30 days)
Hello! I am trying to create a matrix that represents all possible recipie combinations of 3 chemical components. The 3 chemical components must sum to 100 wt%, and individually have an abundace between 0 and 100 wt% . Eventually I want to create a giant matrix of all possible combinations of 10 chemical components, but I'll start off easy with 3 chemical ingredidents.
I want to create the matrix in small increments of around 0.1 wt%.
The end result I am going for would have 3 columns (one for each ingreident), and each row would contain a recipe (e.g., 10.3 wt% ingredient 1, 70.9 wt% ingredient 2, and 18.8 wt% of inregident 3).
Thanks!

Accepted Answer

Davide Masiello
Davide Masiello on 3 Mar 2022
I am going to assume that the percentage of each compound can be rounded to the first decimal digit.
Then I would recommend using the following function:
Given a number n of compunds, the matrix A of all possible recipes is found by
A = allVL1(n,1000)/10;
For n = 3, the first ten rows of the outputs are
A =
0 0 100.0000
0 0.1000 99.9000
0 0.2000 99.8000
0 0.3000 99.7000
0 0.4000 99.6000
0 0.5000 99.5000
0 0.6000 99.4000
0 0.7000 99.3000
0 0.8000 99.2000
0 0.9000 99.1000
...
...
In this case, the size of A is 501501x3, so be careful not to run out of memory when you scale it up to 10 compounds!
  8 Comments
Sterling Vanderzee
Sterling Vanderzee on 4 Mar 2022
Edited: Sterling Vanderzee on 4 Mar 2022
@Davide Masiello and @Stephen, do you think it would be possible to create a reasonalby efficient code that modies the AllVL1 code to only generate chemical compound "recipies" that satisfy a linear constraint on the bulk chemical composition of the mixture (i.e., in cases where I know the bulk chemical composition and want to know the possible recipies)? Maybe that would drastically reduce the amount of memory needed by only focusing on a small subset of the billions of possible recipes?
Davide Masiello
Davide Masiello on 8 Mar 2022
@Sterling Vanderzee I am slightly confused by your terminology.
For instance, when you say the most probable concentration of a specific chemical compund of interest, how is that probability determined?
Are we to understand that there are equations modelling the probability that a certain compound has a certain concentration in your mixture?
If the only constraint is that the sum of all concentrations equals 100, then you are back to the combinatoric problem of all the possible recipes, which is unfeasible for the reasons mentioned above.

Sign in to comment.

More Answers (0)

Categories

Find more on Chemistry in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!