Materials dialogue problem

About the development of the FEM module/workbench.

Moderator: bernd

lambda
Posts: 34
Joined: Sat Feb 25, 2017 3:10 pm
Contact:

Re: Materials dialogue problem

Postby lambda » Tue Oct 10, 2017 9:06 am

@HoWil: It seems like FreeCAD has no built-in declaration and definition for Unit::VolumeExpansionCoefficient. I still don't understand how the Units system works, but maybe that's why in your example this value doesn't seem to parse at all?

The rest looks like locale issues to me. That's different from what I'm currently working on, but either starting FreeCAD on the command line with `LANG=C FreeCAD` or entering the numbers in the format FreeCAD appears to use should work around that and at the same time confirm it's actually a locale problem.

HTH,
Harald
lambda
Posts: 34
Joined: Sat Feb 25, 2017 3:10 pm
Contact:

Re: Materials dialogue problem

Postby lambda » Tue Oct 10, 2017 5:11 pm

PR for the ThermalConductivity Problem:
https://github.com/FreeCAD/FreeCAD/pull/1032

Turns out this was unrelated to the original issues discussed in this thread. Sorry for hijacking the topic.
User avatar
bernd
Posts: 8477
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Materials dialogue problem

Postby bernd » Tue Oct 10, 2017 6:56 pm

Thanks to harald, The unit problem seams fixed in master https://github.com/FreeCAD/FreeCAD/comm ... 3331870c87

@harald its always a good idea to keep the topic updated of you gone make a PR with a fix

bernd
User avatar
bernd
Posts: 8477
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Materials dialogue problem

Postby bernd » Tue Oct 10, 2017 6:58 pm

Damn sorry I somehow missed the post before my one ... To much FreeCAD today ...
HoWil
Posts: 840
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Materials dialogue problem

Postby HoWil » Fri Oct 13, 2017 7:59 pm

lambda wrote:
Tue Oct 10, 2017 9:06 am
The rest looks like locale issues to me. That's different from what I'm currently working on, but either starting FreeCAD on the command line with `LANG=C FreeCAD` or entering the numbers in the format FreeCAD appears to use should work around that and at the same time confirm it's actually a locale problem.
Thx, Harald for this explaination.
But, starting with 'LANG=C' does not resolve the problem, nor using '.' instead or ','.
:?
BR,
HoWil
lambda
Posts: 34
Joined: Sat Feb 25, 2017 3:10 pm
Contact:

Re: Materials dialogue problem

Postby lambda » Sat Oct 14, 2017 1:20 pm

HoWil wrote:
Fri Oct 13, 2017 7:59 pm
But, starting with 'LANG=C' does not resolve the problem, nor using '.' instead or ','.
:?
BR,
HoWil
That's strange, so I looked into this a bit more and realized a couple of things:

* reading 'man 7 locale' I realized that 'LANG' is not the only environment variable affecting locales. There is also LC_* - please try 'env | grep LC' to see if any of those are present on your system.
* maybe also FreeCAD itself sets some locale information, so I tested your examples in a clean sandbox starting with a new document. See below for results. Unfortunately I can't save pictures - FreeCAD always tells me "Can't save null image", so a textual description will need to suffice. (Though if anybody nows how to fix this, please tell me!)
* in 'C' locale FreeCAD uses only '.' not ',' and any locale issues are gone. For example Density now work ok!
* however there appears to be an issue with precision: Only two digits after the decimal marker are shown and values are stored after closing the dialog with this precision only.
* The KinematicViscosity is displayed in mm^2/s instead of m^2/s, but then stored as m^2/s in the document. Here a huge error happens. - I will have a look if this is a problem in the units system like there had been with ThermalConductivity. (Edit: I don't see anything wrong with handling of m^2/s values when using the units system directly from python. It does produce some unwieldy big values sometimes though.)
* Small values are displayed als '0.00' instead of using scientify notation.

So there seems to be a combination of different problems, not all of which necessarily are bugs.

Here is the output from python. In between the dialog was opened and closed again:

Code: Select all

>>> App.ActiveDocument.FluidMaterial.Material
{'Name': u'Air', 'Density': u'1.2 kg/m^3', 'MolarMass': u'28.965', 'KinematicViscosity': u'15.11 m^2/s', 'ThermalExpansionCoefficient': u'0 um/m/K', 'SpecificHeat': u'1.005 J/kg/K', 'VolumetricThermalExpansionCoefficient': u'3.43e-3 m/m/K', 'DynamicViscosity': u'1.80e-5 kg/m/s', 'ThermalConductivity': u'0.0257 W/m/K', 'PrandtlNumber': u'0.7', 'Description': u'Standard air properties at 20 Degrees Celsius and 1 atm'}
>>> App.ActiveDocument.FluidMaterial.Material
{'Name': u'Air', 'Density': u'1.2 kg/m^3', 'MolarMass': u'28.965', 'KinematicViscosity': u'1000.0 m^2/s', 'ThermalExpansionCoefficient': u'0 um/m/K', 'SpecificHeat': u'1.0 J/kg/K', 'VolumetricThermalExpansionCoefficient': u'3.43e-3 m/m/K', 'DynamicViscosity': u'1.80e-5 kg/m/s', 'ThermalConductivity': u'0.03 W/m/K', 'PrandtlNumber': u'0.7', 'Description': u'Standard air properties at 20 Degrees Celsius and 1 atm'}
chrisb
Posts: 19594
Joined: Tue Mar 17, 2015 9:14 am

Re: Materials dialogue problem

Postby chrisb » Sat Oct 14, 2017 5:01 pm

What d
lambda wrote:
Sat Oct 14, 2017 1:20 pm
can't save pictures - FreeCAD always tells me "Can't save null image",
Currently FreeCAD has a problem here, but you can still make a regular screenshot
HoWil wrote:
Fri Oct 13, 2017 7:59 pm
But, starting with 'LANG=C' does not resolve the problem, nor using '.' instead or ','.
When you start FreeCAD with this environment variable set, what does your FreeCAD info says? In the last line it tells you about the locale from FreeCAD's point of view.
Some time ago there were similar problems and IIRC the locale comes from Qt, which possibly does not respect the LC variable.
HoWil
Posts: 840
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Materials dialogue problem

Postby HoWil » Sun Oct 15, 2017 3:38 pm

chrisb wrote:
Sat Oct 14, 2017 5:01 pm
When you start FreeCAD with this environment variable set, what does your FreeCAD info says? In the last line it tells you about the locale from FreeCAD's point of view.
Some time ago there were similar problems and IIRC the locale comes from Qt, which possibly does not respect the LC variable.
I get :

OS: Ubuntu 16.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12372 (Git)
Build type: None
Branch: master
Hash: 76eba3a57904899805f683e1eaf0cbb71b806c83
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: C/Default (C)
chrisb
Posts: 19594
Joined: Tue Mar 17, 2015 9:14 am

Re: Materials dialogue problem

Postby chrisb » Sun Oct 15, 2017 4:25 pm

So we know that FreeCAD respects the environment variable. Which leaves us puzzled with the rest.
HoWil
Posts: 840
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Materials dialogue problem

Postby HoWil » Mon Oct 16, 2017 1:15 pm

Hello,

I think I could fix the problem concerning the restoring of quantity-based values. :D

As described by oliveroxtoby, the values are stored in 'C' locale in e.g. Material-db but have to be converted to the user's locale.
For additional information please see https://forum.freecadweb.org/viewtopic. ... 1a#p189664

I did change all parts in '_TaskPanelFemMaterial.py' accordingly. Here for example the part for Density:

Code: Select all

        if 'Density' in matmap:
            density_new_unit = "kg/m^3"
            density = FreeCAD.Units.Quantity(matmap['Density'])
            density_with_new_unit = density.getValueAs(density_new_unit)
            #self.form.input_fd_density.setText("{} {}".format(density_with_new_unit, density_new_unit))
            q = FreeCAD.Units.Quantity("{} {}".format(density_with_new_unit, density_new_unit))
            self.form.input_fd_density.setText(q.UserString)
Can you (@lambda, @chrisb, @Bernd) please double-check this so Bend can put it in master.
Please see https://github.com/HoWilgh/FreeCAD/comm ... 929be3158e .

BR,
HoWil