da-crivelli / freecad-parametric-fea Goto Github PK
View Code? Open in Web Editor NEWA flexible parametric FEA library based on FreeCAD
License: GNU Lesser General Public License v2.1
A flexible parametric FEA library based on FreeCAD
License: GNU Lesser General Public License v2.1
Most classes are already documented. The build process should also create some form of documentation under /docs.
Modal analysis creates result sets in the form of CCX_EigenMode_{n}_Results
. The number of modes is user-defined in the preferences. We should
Depends on #24
fea.plot_fea_results()
should allow for any optional parameter to be passed down to plotly
.
Leveraging on parametric
, should allow the user to specify
This could effectively be a class that generates runs of parametric
, the results of which are then passed to the optimiser which determines the next run matrix and values.
We should still keep track of all runs in a dataframe, so this may need a new version of the dataframe initialisation function to support appending rather than creating a new df from scratch.
In some cases, a user might want to exclude certain results or provide a non-grid type set of data points.
The workflow could be as follows:
OR
parametric
only runs cases where recalculate==true
The idea is to be able to open a single ParaVIEW collection that includes all of the result meshes.
See the following code suggested by Lufthschraube on the FreeCAD forums:
PVUFile = open(ExportOutputPath + "/" + FileName + ".pvd","w")
PVUFile.write("<VTKFile type=\"Collection\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n\t<Collection>\n")
n = 0
for ExportObject in sorted(FEMResultObjects):
n = n + 1
#Read and format time stamp (e.g., 12.37 s = 0001237)
FreeCADResultLabelParts = ExportObject.split("_")
PreDecimal = FreeCADResultLabelParts[-3]
PostDecimal = FreeCADResultLabelParts[-2]
if len(PostDecimal) == 1:
PostDecimal = PostDecimal + str(0)
TimeValue = float(PreDecimal) + float(PostDecimal)/100
TimeString = str(int(round(TimeValue*100,0))).zfill(7)
#For some reason, the VTK exporter expects a list (although only one object is processed at once...) - so build a list with the current object
ExportObjectList = []
ExportObjectList.append(FreeCAD.ActiveDocument.getObject(ExportObject))
FileNameOUT = FileName + "_" + TimeString + ".vtu"
FilePath = ExportOutputPath + "/" + FileNameOUT
FreeCAD.Console.PrintMessage(FilePath + " is to be created\n")
feminout.importVTKResults.export(ExportObjectList,FilePath)
PVUFile.write("\t\t<DataSet timestep=\"" + str(TimeValue) + "\" file=\"" + FileNameOUT + "\"/>\n")
#Close the .pvu file
PVUFile.write("\t</Collection>\n</VTKFile>")
PVUFile.close()
Currently the output selection is ignored, and defaults to max. Von Mises and max. displacement. These are used for plotting after all test cases are run, and added to the results dataframe.
The user shall be able to select the output parameters as follows:
fea.set_outputs(
[
{
"output_var": "vonMises",
"reduction_fun": np.max,
},
]
)
The reduction_fun
should be a function handle to reduce output_var
to a single value.
If a user wants to write their own reduction function (e.g. Galileo - Rankine criterion, or a custom safety factor output) they currently would need to use some post-processing in Paraview or other software.
In a future version this should be possible:
fea.set_outputs([{
"output_var": ("s1","s2","s3"),
"reduction_fun": myfun,
}])
def myfun(s1, s2, s3):
return something
The README.md file should be improved to include:
We should support logging instead of printing.
Log files should be local to the script (as it makes sense to inspect an analysis after running it, rather than having to look at system level logs) but the user should also be allowed to specify their log folder if they wish so. Maybe do when setting up parametric()?
Careful not to break tqdm
but also should be meaningful.
This is a good starting point: https://guicommits.com/how-to-log-in-python-like-a-pro/
We should run the code against some benchmarks - for example: https://www.nafems.org/community/working-groups/education-and-training/nafems_benchmark_challenge/
With some magic, can we get a model (or a view) set up, highlighting the parameters that will be changed as an annotation?
The user should be able to decide where the .vtk results go when calling fea.run_parametric(export_results=True)
When dealing with over 2 parameters, it will become difficult to show everything in a 2d plot. Either:
When running a batch analysis, the following is output at every iteration:
[{'ccx_elset': 'Evolumes', 'ccx_elset_name': 'MaterialSolidSolid', 'mat_obj_name': 'MaterialSolid', 'ccx_mat_name': 'Aluminum 6061-T6'}]
This happens in freecadmodel.py
in one of these lines:
fea = femtools.ccxtools.FemToolsCcx(solver=solver_object)
fea.purge_results()
fea.reset_all()
fea.update_objects()
save_fea_results
should allow exporting the dataframe as .pickle
The user should be allowed to specify a list of FreeCAD material names in order to check the performance of a component against a range of materials.
This may already be possible, but is untested. If it's possible, then it should be added to the examples.
_register_freecad
should try and find FreeCAD in the default folders if not specified by the user.
C:\Users\<username>\AppData\Local\Programs\FreeCAD X.YY
orC:\Program Files\FreeCAD X.YY
On Linux: need to find out
On Mac: /Applications/FreeCAD.app/
FEA is dimensionless (assumes consistency in inputs); however, FreeCAD has knowledge of units, and does conversion between SI and non-SI or base-SI (m g s) to sub/super units (mm kg s)
We should store the units of inputs and outputs in the Dataframe or somewhere accessible so that the plots and outputs show the correct units.
The package should be extremely easy to install via pip
/ pipenv
/ poetry
to ensure any adoption.
We should add a /tests suite before opening to pull requests, etc.
Currently we're only supporting netgen meshes. It's not ideal, it would be great if we could support gmsh meshes. The main issue is that the gmsh mesh won't recalculate automatically, but surely we can find a way?
The output selection should allow the user to define a nodeset / element set over which to calculate the desired value (e.g. max over a plane, max. over a line)
To simplify user input we shouldn't really require them to specify the results_object
name. We could easily cycle over standard names or figure out which object(s) contain results. Keep the option available if the user wants to rename the object.
The .vtk file as generated at the moment is a plain text file. Sounds a bit wasteful, is there a way to compress it or switch to a compressed format? We can run the compression after all results have been written.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.