Skip to content

Commit

Permalink
fix: the lock equiv. not working if amount_mol of the reference is ch…
Browse files Browse the repository at this point in the history
…anged
  • Loading branch information
Tasnim Mehzabin committed Jan 30, 2025
1 parent babc94f commit 90d5e7a
Showing 1 changed file with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,14 @@ export default class ReactionDetailsScheme extends Component {
return sample;
}
sample.maxAmount = referenceMaterial.amount_mol * stoichiometryCoeff * sample.molecule_molecular_weight / (sample.purity || 1);
// yield taking into account stoichiometry:
if (updatedSample.gas_type === 'gas') {
const equivalent = this.calculateEquivalentForGasProduct(sample, vesselVolume);
sample.equivalent = equivalent > 1 ? 1 : equivalent;
} else {
sample.equivalent = sample.amount_mol / referenceMaterial.amount_mol / stoichiometryCoeff;
if (!lockEquivColumn) {
// yield taking into account stoichiometry:
if (updatedSample.gas_type === 'gas') {
const equivalent = this.calculateEquivalentForGasProduct(sample, vesselVolume);
sample.equivalent = equivalent > 1 ? 1 : equivalent;
} else {
sample.equivalent = sample.amount_mol / referenceMaterial.amount_mol / stoichiometryCoeff;
}
}
} else {
if (!lockEquivColumn) {
Expand All @@ -806,14 +808,15 @@ export default class ReactionDetailsScheme extends Component {
unit: 'mol'
});
}

}
}
} else {
if (materialGroup === 'products' && sample.gas_type !== 'gas') {
sample.equivalent = 0.0;
} else {
sample.equivalent = 1.0;
if (!lockEquivColumn) {
if (materialGroup === 'products' && sample.gas_type !== 'gas') {
sample.equivalent = 0.0;
} else {
sample.equivalent = 1.0;
}
}
}
} else {
Expand All @@ -833,29 +836,29 @@ export default class ReactionDetailsScheme extends Component {
}
}

if ((materialGroup === 'starting_materials' || materialGroup === 'reactants') && !sample.reference) {
// eslint-disable-next-line no-param-reassign
sample.equivalent = sample.amount_mol / referenceMaterial.amount_mol;
} else if (materialGroup === 'products'
&& (sample.equivalent < 0.0 || isNaN(sample.equivalent) || !isFinite(sample.equivalent))
&& sample.gas_type !== 'gas') {
// if (materialGroup === 'products' && (sample.equivalent < 0.0 || sample.equivalent > 1.0 || isNaN(sample.equivalent) || !isFinite(sample.equivalent))) {
// eslint-disable-next-line no-param-reassign
sample.equivalent = 1.0;
} else if ((materialGroup === 'products' && (sample.amount_mol === 0 || referenceMaterial.amount_mol === 0)
&& sample.gas_type !== 'gas')) {
// eslint-disable-next-line no-param-reassign
sample.equivalent = 0.0;
} else if (materialGroup === 'products' && sample.amount_g > sample.maxAmount && sample.gas_type !== 'gas') {
// eslint-disable-next-line no-param-reassign
sample.equivalent = 1;
this.triggerNotification(sample.decoupled);
if (!lockEquivColumn) {
if ((materialGroup === 'starting_materials' || materialGroup === 'reactants') && !sample.reference) {
// eslint-disable-next-line no-param-reassign
sample.equivalent = sample.amount_mol / referenceMaterial.amount_mol;
} else if (materialGroup === 'products'
&& (sample.equivalent < 0.0 || isNaN(sample.equivalent) || !isFinite(sample.equivalent))
&& sample.gas_type !== 'gas') {
// eslint-disable-next-line no-param-reassign
sample.equivalent = 1.0;
} else if ((materialGroup === 'products' && (sample.amount_mol === 0 || referenceMaterial.amount_mol === 0) && sample.gas_type !== 'gas')) {
// eslint-disable-next-line no-param-reassign
sample.equivalent = 0.0;
} else if (materialGroup === 'products' && sample.amount_g > sample.maxAmount && sample.gas_type !== 'gas') {
// eslint-disable-next-line no-param-reassign
sample.equivalent = 1;
this.triggerNotification(sample.decoupled);
}
}
}

if (materialGroup === 'products') {
if (typeof (referenceMaterial) !== 'undefined' && referenceMaterial) {
sample.maxAmount = referenceMaterial.amount_mol * stoichiometryCoeff * sample.molecule_molecular_weight / (sample.purity || 1);;
sample.maxAmount = referenceMaterial.amount_mol * stoichiometryCoeff * sample.molecule_molecular_weight / (sample.purity || 1);
}
}
return sample;
Expand Down

0 comments on commit 90d5e7a

Please sign in to comment.