-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Pkynetics Version
0.5.0
Python Version
Python 3.9, 3.10, 3.11
Operating System
All
Bug Description
The CpCalculator, when used with operation_mode=OperationMode.STEPPED, does not correctly process data from stepped-isothermal experiments. Instead of averaging the signal over the stable portion of each isothermal plateau, it appears to process all data points individually. This results in scattered and physically incorrect Cp values, particularly when there is signal instability at the start of an isotherm.
Steps to Reproduce
The issue is reproducible using the stepped_isothermal_cp_example.py script. The synthetic data portion of the example shows the problem clearly.
# The following call demonstrates the issue.
# The `cp_result` contains scattered, incorrect values instead of one
# distinct Cp value per isotherm.
cp_result = calculator.calculate_cp(
temperature=sample_data["temperature"],
heat_flow=sample_data["heat_flow"],
sample_mass=sample_mass,
heating_rate=20.0,
method=CpMethod.THREE_STEP,
operation_mode=OperationMode.STEPPED,
reference_data=reference_data,
)Expected Behavior
When operation_mode=OperationMode.STEPPED is used, the CpCalculator should internally perform the following actions:
- Identify the isothermal plateaus from the input data.
- For each plateau, determine the stable region (e.g., by discarding the initial transient portion).
- Calculate the single average heat flow value for the sample, reference, and blank signals over this stable region.
- Return one correct Cp value for each identified isotherm.
Actual Behavior
The calculator processes all data points within the isothermal regions, leading to a large number of scattered and incorrect Cp values. This forces the user to manually segment, trim, and average the data before calling the calculator, which negates the purpose of the STEPPED mode.
Error Message & Stack Trace
N/A. The issue is an incorrect calculation, not a crash or exception.Additional Context
This bug was identified during the development of the stepped_isothermal_cp_example.py (related to issue #64). The example script currently contains a manual workaround where the isothermal data is averaged before the final calculation. This workaround should be removed once the CpCalculator is fixed.
Guidelines
- I agree to follow this project's Contributing Guidelines
- I have searched for similar issues before creating this one