BAMresearch / fenics-constitutive

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

How to deal with units #25

Closed eriktamsen closed 8 months ago

eriktamsen commented 2 years ago

I felt like this issue should be seperated from Thomas question in #16. Here a short summary or my thoughts and Thomas first suggestion.

Units are generally annoying, as models, especially with many different input paramters need to use consistent units. One fun example from my past experience is: How to scale the density from kg/m³ to a problem, which uses N as force and mm als length. If I remember correctly you have to multiply by 10^-12, not very intuitive. Anyways, my point is, having a structured way of dealing with units can save you a lot of time. In the frame of our fenics-module we have the added problem, that we might want to compare experimental data to our simulation data, where the units could differ. This issue is definitly not a priority, but if I think about how much time I have wasted by paramters in the wrong units. I believe I it worth thinking about.

Thomas suggested: 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)

I found this package: Pint If I remember correctly, Volker has suggested this to me once, so there is a chance the this can be integrated even with Fenics. Does anyone have experience this this? When I have some time, I will try and see if it works, as expected.