private void SubstituteValue(int oldSteadyStateValueIndex, SteadyStateEquation SubEquation) { decimal p = SteadyStateValues[oldSteadyStateValueIndex].Value; foreach (SteadyStateValue newSteadyStateValue in SubEquation.SteadyStateValues) { SteadyStateValues.Add(new SteadyStateValue(newSteadyStateValue.PiName, newSteadyStateValue.Value * p)); } SteadyStateValues.RemoveAt(oldSteadyStateValueIndex); }
private void SolveStepOne(ref bool needsSolving) //NOTE: not entirely necessary unless showing working is required { //step 1: take relevant value out for (int i = SteadyStateValues.Count - 1; i >= 0; i--) { if (SteadyStateValues[i].PiName.Equals(Equivalent.PiName)) { Equivalent.Value = 1 - SteadyStateValues[i].Value; SteadyStateValues.RemoveAt(i); needsSolving = true; break; } } }
public void Consolidate() { List <int> removalIndices = new List <int>(); for (int i = SteadyStateValues.Count - 1; i >= 0; i--) { for (int j = SteadyStateValues.Count - 1; j >= 0; j--) { if (i != j && SteadyStateValues[i].PiName.Equals(SteadyStateValues[j].PiName) && !removalIndices.Contains(j)) { decimal p = SteadyStateValues[i].Value; removalIndices.Add(i); SteadyStateValues[j].Value += p; } } } removalIndices.ForEach(i => SteadyStateValues.RemoveAt(i)); writeEquationToTex(ToString()); }