Devlog #3
I have implemented the chemical adjustment system. Essentially, you give it a set of chemical amounts and tell it to adjust one of them while conserving the total amount of each element in the system. This ended up being really hard to implement and I had to try many different things to get it to work.
First, I tried using the null space vector to change each value in the element vector, which worked in conserving the element counts but it ended up being almost impossible to ensure every chemical had an amount greater than zero. The math doesn’t care about negative numbers, but you definitely can’t have negative 10 moles of hydrogen. Unfortunately, this approach wasted several hours of my time.
Next, I tried another approach that was a bit dumber but much more successful. It uses a bit of matrix magic to lock one value in place (the one you’re modifying) and change others to keep the element conservation.
The second approach worked great and next update I should be able to implement the Gibbs free energy minimizer, and after that, finally finish my chemical equilibrium solver.
Linear algebra is freaking awesome and magical.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.