Material overhaul

A forum to discuss the implementation of a good Materials system in FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Material overhaul

Post by grandcross »

Looking forward to post 0.21 release, I want to start a discussion thread to cover how Materials should work, without constraining it to how they work now, or changes proposed previously. This may mean refactoring code that is external to materials like architecture and FEM, and any external workbenches.

Yes, I have read this thread: viewtopic.php?t=16714 I haven't built and tested the code yet, but I will shortly. I don't want to comment on all the ideas in this build until I've had a chance to play with it.

I have some ideas for how things should work, but I'm keeping an open mind here. Some ideas may be discarded, while others merely need enhancement.

A summary of what I'm thinking, and some of this has been covered before elsewhere:

1. If it has a shape, it can have a material. Setting the material should be a matter of right clicking. Material properties are inherited, but overridable. Multi-material objects should also be handled and there a number of options for that. The physical properties of the material should automatically be applied where appropriate. For example, mass, center of gravity, etc. should be set when the material is set.

2. The default appearance should be that of the material, unless overridden. Obviously that means it should be possible to be overridden. Appearance workflows will need to be integrated with the materials. That means the materials in the appearance dialog should use the same materials available in FEM, for example. Cards can be created to replace the hard coded appearance values.

3. Where possible, it should be transparent to the user. For example, materials are assigned to the objects. Documents should not require Material dictionaries in the project tree. This could be an optional feature, or perhaps a summary table produced by a right click or menu option. I wouldn't read this bullet as a requirement so much as a goal. This is an area where I'm keeping an open mind.

4. One source for materials. Everything is specified in a card. As I understand it the previous attempt used an object that allowed for multiple data sources. I still need to look into this to understand it properly but this seems to be undesirable to me.

5. Material Cards need to be enhanced. For example, some physical properties may vary with temperature. It should be possible to specify properties for specific value ranges. Default values for those ranges should be specifiable in the material configuration: STP, NTP, or customizable values, etc. Similarly direction should be specifiable. For example, carbon fiber direction, or wood grain directions.

6. Saving material properties in the document should be optional, configurable via preferences. This should help with bullet 3

7. Some types of import/exports can be enhanced to include material information

These are just thoughts and open to discussion. I'll be first to admit that there's a lot I don't know. Rants are welcome. What else would you like to see?

Some other information I'd like to know before beginning:

1. What workbenches currently use materials? (e.g. Arch, FEM, etc.)

2. What EXTERNAL workbenches use materials?

3. What imports/exports use or could use material information?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Material overhaul

Post by yorik »

This is a very good overview of the problem. Materials in FreeCAD is a large thing that spans on different areas (object aspect -> -> physical properties). And there is the problem of how they are represented to the user. And the problem of how they are kept/stored.

I believe the cards system we now have is good. Cards are not tied to anything, they are easily editable and very flexible. I think we should build from there.

The main users of materials inside FreeCAD are indeed Arch and FEM. Another external one that uses them AFAIR is Render. But any other WB that uses simulations like openfoam should be using them too.

I'd say the main thing here is to design a good UI/UX workflow.

Have a look too at the materials manager in the BIM workbench. Not the perfect thing but close to what I imagine would be handy
jedbrown
Posts: 11
Joined: Fri Mar 31, 2023 3:45 pm
Contact:

Re: Material overhaul

Post by jedbrown »

I would like to add material characterization support to FEM workbench (along with a new solver we've been developing). For that, I'd like a way to represent uncertainty in material parameters. In the simplest case, this might be a material with a nominal value and (max, min) bounds on elastic moduli and yield stress/hardening parameters, but many will want Weibull distribution parameters. In a Bayesian context, this input would be called the prior, and after a characterization solve, the FEA tool would create a new card with the posterior (better constrained based on matching experiments).

Typically, a material is characterized by a "simple" experiment like a dog-bone necking or nano-indentation, and the characterized material ("posterior card") is used in larger/more complicated geometry and loading scenarios. It would be good to be able to store some provenance information in the posterior card.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Material overhaul

Post by grandcross »

I'm trying to do a proper requirements analysis for this as its effects can be far reaching. I've already contacted some people for a zoom session as I can get more information talking face to face.

If I haven't contacted you and you would like to have input, message me and I'll set something up.

You can also continue to post here. I'll post summaries as I go so that everyone can see what's going on.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Material overhaul

Post by grandcross »

The requirements gathering is progressing and I promised updates so here goes. In this post I'm going to discuss the material cards and associated UI. A lot of the rest of the overhaul is going to flow from there. This is still a work in progress so feel free to add you $0.02 now before things solidify. I'll be prototyping some of this over the next week so it will be easier to visualize. I'll show them as they become available.

The overall consensus is that the cards have worked well, but are limited. The capabilities will need to be expanded to support a number of workflows. Desired features are:
  • Inheritance - you only specify what's different in your custom material. All other values are in the parent
  • Expanded values - in the current implementation they're simple name value pairs, with the value being a string, float, int, etc. Some other values that are desirable include
    • Distributions and associated parameters
    • Upper and lower bounds
    • Temperature series
    • Arrays
  • DOI citation lookups (https://doi.org). This will be similar to a description in that it is documentation, but it should be possible to link from the UI
  • Units field - this can improve validations as well as aid in documentation. This would be a type such as 'Pressure' rather than the units such as 'MPa' to accommodate user preferences for units
For mechanical properties, there are situations where the current linear elastic model (Shear modulus, Young's modulus, poisson ratio) are insufficient. It should be possible to add non-linear (or other) models through an API and edit them in the UI. In many cases these models would provide their own parameter templates that may specify very different physical properties. This mechanism is currently being refined.

For the UI, the organization will change. A combobox was sufficient for the models currently supplied but as the number of models increases it quickly becomes unmanageable. A tree view will organize materials into libraries and folders. System (and workbench) libraries will be considered immutable. Changes must be saved to a custom card. A favourites folder would be at the top. This could be for materials already in use in the model, or for ones explicitly marked as favourite. When a property is edited, system cards would be saved as a custom card. For custom cards it can overwrite the existing card, or saved into a new card.

Properties will be separated into tabs based on the category. For example, General, Physical, Appearance, and Costs. Some properties may be added or removed as the workflow is improved. For example, the "Father" property may be replaced by something more appropriate when inheritance is implemented.

These changes are likely to break existing workbenches. For core workbenches such as FEM and Arch, any required fixes will be done. External workbenches may require some changes by the maintainers. The biggest impact will be in value lookups, as they will now return an object rather than a value. APIs will be made available to both C/C++ and Python developers to minimize their workload.

As I mentioned earlier in the post, expect some prototypes soon. This will help in the visualization.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Material overhaul

Post by adrianinsaval »

grandcross wrote: Tue May 09, 2023 4:34 pm 4. One source for materials. Everything is specified in a card. As I understand it the previous attempt used an object that allowed for multiple data sources. I still need to look into this to understand it properly but this seems to be undesirable to me.
What do you mean with one source of materials? Does this mean that an user cannot define their own library of materials? I don't agree with that.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Material overhaul

Post by grandcross »

adrianinsaval wrote: Thu May 25, 2023 7:25 pm What do you mean with one source of materials? Does this mean that an user cannot define their own library of materials? I don't agree with that.
It just means they would be defined in one place. Currently FreeCAD defines physical and appearance properties using material cards, while the appearance dialog has a set of hard coded materials that are completely separate and include appearance properties only. The previous attempt tried to accommodate both, but we would eliminate the latter and only use cards. The current proposal would in fact enhance the users ability to create and use their own libraries.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Material overhaul

Post by adrianinsaval »

Ah that makes sense and it's very good, looking forward to this improvement! A tangent missing feature here is the ability to obtain center of gravity for Parts, right now I think FreeCAD does not take into account difference in density and treats all elements inside a Part container to have unitary density, it would be nice if once there is proper material support that the center of gravity is calculated taking this into account. I think we don't have a way to directly get the weight of an object either.

In regards to that it might also make sense to have the possibility to specify density for surfaces, to model for example aircraft skins as just surfaces that will be treated as having thickness when calculating weight. This might be out of scope of your intent though, but keep in mind as possible future usage.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Material overhaul

Post by grandcross »

adrianinsaval wrote: Thu May 25, 2023 8:03 pm Ah that makes sense and it's very good, looking forward to this improvement! A tangent missing feature here is the ability to obtain center of gravity for Parts, right now I think FreeCAD does not take into account difference in density and treats all elements inside a Part container to have unitary density, it would be nice if once there is proper material support that the center of gravity is calculated taking this into account. I think we don't have a way to directly get the weight of an object either.

In regards to that it might also make sense to have the possibility to specify density for surfaces, to model for example aircraft skins as just surfaces that will be treated as having thickness when calculating weight. This might be out of scope of your intent though, but keep in mind as possible future usage.
This is something that we will be digging in to. Right now for example selecting a material isn't automatically applied to a part for things like CG or mass even though these capabilities are there.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Material overhaul

Post by yorik »

This looks like a very good plan!

A couple of $0.02 ideas:

- Maybe writing unit tests for Arch and FEM that test material support would be handy here so we can detect incompatibility issues early. For Arch there is one already: https://github.com/FreeCAD/FreeCAD/blob ... ch.py#L399 but we might add a simpler one. For FEM I'm not sure

- Think of the possibility for workbenches to implement some sort of "micro-editor". Some workbenches might want to work with only a few material parameters, and will not want to use the full-fledged material editor. Maybe you could design your UI code in a way that some parts of it could be reused by others (I'm thinking for example, of the materials tree)

- Some external resources might be needed, like texture images, or hatch patterns. These might be a simple file path, or an URL, but I imagine these could also be embedded, so we have a self-contained material. The ability to embed any kind of data could also be useful for the complex cases you described, I imagine a whole table or diagram or formula could be embedded too.
Post Reply