コード例 #1
0
def example_dilute_to_required_mass_concentration() -> None:
    """Dilute a given amount of source material to solution of the required size
    10mg to 120ug/ul"""
    original_mass = parse("10mg")
    target_conventration_by_mass = parse("120ug/ul")
    required_volume = original_mass / target_conventration_by_mass
    print(f"Required diluting agent volume is {required_volume}")
コード例 #2
0
def example_dilute_to_required_molar_concentration() -> None:
    """5mg powder to 20mM"""
    powder_mass = parse("5mg")
    target_dilution = parse("20mM")
    powder_molecular_weight = parse("544.43g/mol")
    powder_mols = powder_mass / powder_molecular_weight
    diluting_agent_volume = powder_mols / target_dilution
    print(
        f"The required diluting agent volume is {diluting_agent_volume.as_units('ul')}"
    )
コード例 #3
0
def example_compare_solutions_strength() -> None:
    """Convert 5 ug/ul to mM and compare with a 20mM solution"""
    solution1_concentraion_by_mass = parse("5ug/ul")
    solution2_molar_concentration = parse("20mM")
    molecular_weight = parse("544.43g/mol")
    solution1_molar_concentration = solution1_concentraion_by_mass / molecular_weight
    sol2_to_sol1_concentraion_ratio = (solution2_molar_concentration /
                                       solution1_molar_concentration)
    if solution1_molar_concentration > solution2_molar_concentration:
        print("Solution 1 is stronger!")
    else:
        print("Solution 2 is stronger!")
    print(
        f"Solution 2 is {solution2_molar_concentration - solution1_molar_concentration} mM over solution 1"
    )
    print(
        f"Solution 2 [20mM] is {sol2_to_sol1_concentraion_ratio} as strong as solution 1 [5ug/ul]"
    )
コード例 #4
0
def test_parse_complex_units() -> None:
    _jA = parse("jA")
    assert repr(_jA) == "1jA"
    _3p2jA = parse("(3+2.5j)A")
    assert repr(_3p2jA) == "(3+2.5j)A"
コード例 #5
0
def test_parse_vloat_units() -> None:
    _2500ms = parse("2.5s")
    assert _2500ms == Milliseconds(2500)
コード例 #6
0
def test_prase_int_units() -> None:
    _5m = parse("5m")
    _25m2 = parse("25m^2")
    assert repr(_5m) == "5.0m"
    assert _5m * _5m == _25m2