Skip to content

Cannot take a subsample of a solution #55

Description

@GeertD

Hi,

First of all, two thumbs up for this great library!
It greatly enhances working with PhreeQC.

I'm mixing solutions:
sol3 = sol1*0.8 + sol2*0.2

This works fine, but one has to keep the sum of the fractions = 1, otherwise the new solution has a mass > 1.0, which makes it harder to interpret the species amounts (all in mol):

sol3 = sol1*8.0 + sol2*2.0
sol3.mass
>> 10.0

I thought easy as, we'll just take a subsample to get to water mass = 1.0 again:
sol3 = sol3 / sol3.mass

No errors, but:

sol3.mass
>> 10.0 (no change)

I had a look at the code (solution.py), and the magic div() method only changes sol.factor, it does not mix to create a new solution (subsample).

An rather ugly workaround:

sol_empty = pp.add_solution({'-water': 0.0})
sol4 = sol3*0.1 + sol_empty
sol4.mass
>> 1.0

This triggers the mixing of the solutions, and adds an dummy empty solution.

It would be much more intuitive if multiplying a single solution with a factor would actually change the solution amount (instead of the internal solution.factor).

Best regards,
Geert

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions