Coder Social home page Coder Social logo

da-crivelli / freecad-parametric-fea Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 4.0 21.55 MB

A flexible parametric FEA library based on FreeCAD

License: GNU Lesser General Public License v2.1

Python 99.77% Makefile 0.23%
finite-element-analysis freecad python structural-analysis structural-engineering

freecad-parametric-fea's People

Contributors

da-crivelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

freecad-parametric-fea's Issues

Add documentation

Most classes are already documented. The build process should also create some form of documentation under /docs.

Support modal analysis

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

  • find out what type of analysis we're doing
  • if modal, just extract the modes (user shouldn't be required to specify the results object)

Depends on #24

Develop optimisation tool

Leveraging on parametric, should allow the user to specify

  • An objective function
  • Which parameters to change
  • Boundaries / limits
  • An optimisation method
  • A minimum error

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.

Allow a user to provide their own data frame

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:

  • User runs a dry run and obtains a blank dataframe
  • User manipulate data frame
  • User calls the analysis with a user provided dataframe

OR

  • user has an existing dataset or an analysis that needs resuming / refining
  • user sets an additional "recalculate" column to true/false
  • parametric only runs cases where recalculate==true

Package .vtk files in a single scene

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()

Make the outputs scriptable / selectable

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.

Allow multiple parameters for custom output function

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

Add logging

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/

Better define plot when >2 parameters

When dealing with over 2 parameters, it will become difficult to show everything in a 2d plot. Either:

  • some dataviz magic / surface / isolines (but then the problem appears again above 3 parameters)
  • a matrix of parameter pairs? (e.g. main effects plot in other software)

Running CalculiX prints unnecessary stuff to stdout

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()

Test parametric materials

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.

Smart finding of FreeCAD path

_register_freecad should try and find FreeCAD in the default folders if not specified by the user.

On Windows:

  • C:\Users\<username>\AppData\Local\Programs\FreeCAD X.YY or
  • C:\Program Files\FreeCAD X.YY

On Linux: need to find out

On Mac: /Applications/FreeCAD.app/

Data should carry units

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.

add test suite

We should add a /tests suite before opening to pull requests, etc.

Support gmsh

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?

Allow selecting node sets for outputs

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)

Autodiscovery of CCX results object

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.

Compress vtk file

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.