BAMresearch / fenics-constitutive

Complex constitutive models beyond the FEniCS UFL.
https://bamresearch.github.io/fenics-constitutive
MIT License
13 stars 2 forks source link

Better comparison of sensor outputs #16

Closed TTitscher closed 5 months ago

TTitscher commented 2 years ago

When comparing the sensor outputs (e.g. model vs data, model vs analytic), we currently use try/except blocks and different methods to somehow choose between:

a - b                         # scalars or numpy arrays
a.vector()[:] - b.vector()[:] # df.Function
np.linalg.norm(a - b)         # norm of scalars or numpy arrays
df.errornorm(a, b)            # norm of df.Function
df.errornorm(a, b)/df.norm(a) # scaled norm of df.Function

and introducing several time steps certainly complicates the issue.

How can we improve that? With the assumption that we mostly (only??) compare outputs of the same sensor or sensor type, my first idea is to add something like a compare method to the sensor. More ideas are welcome!

eriktamsen commented 2 years ago

Not solving the problem, but adding to it: should we think about units? What if my experimental data is given in kN and my problem gives N. Do we want to include this?

TTitscher commented 2 years ago

A pattern that previously worked for me was to equip the sensors with a "unit_factor" that is multiplied to all measurements.

experiment, sensor, model = ...
experiment.add_sensor_data(sensor, data_in_kN)

sensor.unit_factor = 1
model_response_in_N = model.evaluate(sensor)

sensor.unit_factor = 1000
model_response_in_kN = model.evaluate(sensor)

That fails, if the same sensor is used to "measure" different models with different units. Is that a common case?

eriktamsen commented 2 years ago

At least from my point of view, this should not be a common case, if at all. If we follow the sensor concept outlined in #24, the senors would be applied directly to the problem.

I have moved the question of how to deal with units to #25, as the initial question of how to compare sensor output (assuming the units are not a problem) is not addressed.

joergfunger commented 2 years ago

I would suggest to query/reading in the data with units that the model provides (so that reading in the sensor values requires to think about the units in the database and the requirements of the model). The transformation/conversion could then happen at this place.