compas-dev / compas_fea2 Goto Github PK
View Code? Open in Web Editor NEWFinite Element Analysis toolbox for the COMPAS framework.
Home Page: https://compas.dev/compas_fea2
License: MIT License
Finite Element Analysis toolbox for the COMPAS framework.
Home Page: https://compas.dev/compas_fea2
License: MIT License
In abaqus.parts line 118, this import should be at the top
# Write sets
for section in self.elements_by_section:
#TODO this part is messy and needs to be rewritten
# the main problem is that beam elements require orientations
# while other elements (such shells) don't
o=1
for orientation in self.orientations_by_section[section]:
from compas_fea2.backends.abaqus.model import Set <<<< HERE
elements = []
for element in self.elements_by_section[section]:
if hasattr(self.elements[element], 'orientation') and self.elements[element].orientation == orientation:
elements.append(element)
elif not hasattr(self.elements[element], 'orientation'):
elements.append(element)
self.add_element_set(Set('_{}-{}'.format(section, o), elements, 'elset'))
o+=1
it is currently possible to use only material subroutines (and one per time) in compas_fea2.
To use multiple subroutines at the same time in Abaqus, the fortran (or C++) files need to be combined.
It could be interesting to automatically combine them if the user specifies more than one.
I can see everywhere this object components = {'x': x, 'y': y, 'z': z, 'xx': xx, 'yy': yy, 'zz': zz}
I would rather create a component like this:
class Components:
def __init__(x=0. y=0, z=0, xx=0, yy=0, zz=0):
self.x = x
self.y = y
etc...
after it's much easier to access the individual components self.components.x
is much lighter than self.components['x']
also we can add plenty of helpers inside the components class
While browsing the abaqus.model files, I could see that the docstrings were not up-to-date
most FEA software are unit-independent, but you still need to be consistent with the unit chosen. For example, if you use mm
, s
, ton
then you need to specify stresses in MPa. This can be a huge source of errors, especially when the target user is not an engineer.
I am thinking of adding an (optional) parameter to the Model class to specify the units to be used for consistency checks.
These checks can be done for example by comparing the order of magnitude of certain elements (for example, the width and height of a section, or the density of a material) and pop up warnings in the log files.
I have also found this very interesting library: https://pint.readthedocs.io/en/0.10.1/tutorial.html
with this library, it is very easy to convert units and even use not-consistent units at the same time (the conversion happens in the background)
In the file compas_fea2.backends.abaqus.model.materials
line 276, as mentioned in the TODO
I have added, I am sure self.constants
does not belong inside the constant list and should be excluded.
def get_constants(self):
constants = []
for k in self.__dict__:
# TODO: I think we should we add constants in the list below?
if k not in ['__name__', 'name', 'attr_list', 'sub_path', 'p']:
constants.append(self.__dict__[k])
return constants
I propose this:
def get_constants(self):
constants = []
for k in self.__dict__:
if k not in ['constants', '__name__', 'name', 'attr_list', 'sub_path', 'p']:
constants.append(self.__dict__[k])
return constants
I think lots of functions are not so obvious to understand and could easily lead to bugs.
Writing unitary test for them within unittest framework would be a great idea for:
Example with this:
class Steel(SteelBase):
def __init__(self, name, fy, fu, eu, E, v, p):
super(Steel, self).__init__(name, fy, fu, eu, E, v, p)
self.data = self._generate_data()
def _generate_data(self):
data_section = []
line = """*Material, name={}
*Density
{},
*Elastic
{}, {}
*Plastic""".format(self.name, self.p, self.E['E'], self.v['v'])
data_section.append(line)
for i, j in zip(self.compression['f'], self.compression['e']):
line = """{}, {}""".format(abs(i), abs(j))
data_section.append(line)
return '\n'.join(data_section)
If you take a month of holiday and I am in charge of the maintenance without knowing Abaqus, your part of the code, a small test case for this function will give me all the cards in my hand for fixing a bug. I will know exactly what is inside each variable and what to expect from the function.
provide log information during the analysis in the stdout
Hi @franaudo ,
I will start simple with the code review. I have seen several multilines string written in this form on your code:
class Something:
def do_something(self):
DO SOMETHING
DO SOMETHING ELSE
return """line{}
line{}
line{}
""".format(a, b, c)
I find this hard to read, it's also not convenient because it makes de code messy, indentation "beauty" is broken.
Why not writing this instead?
class Something:
def do_something(self):
DO SOMETHING
DO SOMETHING ELSE
return ("line{}\n"
"line{}\n"
"line{}").format(a, b, c)
The only cons are that you need to explicitly write \n
In utilities there should be only methods that the user might need. Everything that is needed by the backend should be in _core
Hi
How to install fea2?
All the analysis methods are now part of the 'Structure' class, but they should be independent. For example, right now it is not possible to use a previously made input file to run an analysis.
I am not PEP8 rigid as some other developers but some stuffs are, let's say more than standard.
__name__ == "__main__":
#
###
#
or
#
# -- Part 1 -------
#
or whatever
Currently , an abaqus job is sent through a command similar to the following:
abaqus cae noGUI=launch_job.py job=xxx.inp cpus=xxx
where the launch_job.py
script contains the info for the job submission.
However:
Simple if/else statements
Inline if/else
are very useful and make the code lighter when the conditions are very simple.
I would replace:
if nlgeom:
self.nlgeom = 'YES'
else:
self.nlgeom = 'NO'
with
self.nlgeom = 'YES' if nlgeom else 'NO'
Exemple above seen in abaqus.steps line 74
Use of super
For information you can use super().__init__
instead of super(MyClass, self).__init__
Include simple implementation examples directly in the doc strings, like:
Parameters
----------
xyz : list
[x, y, z] co-ordinates of the node.
x : float
x co-ordinates of the node.
y : float
y co-ordinates of the node.
z : float
z co-ordinates of the node.
ex : list
Node's local x axis.
ey : list
Node's local y axis.
ez : list
Node's local z axis.
mass : float
Mass in kg associated with the node.
label : string
Node's label. If no label is specified, it is automatically generated
when a node is added. The label does not need to be unique.
key : int
Node key number. The key number is unique.
Examples
--------
>>> node = Node(1.0, 2.0, 3.0)
"""
add links to the official abaqus documentation in the docstrings
it is possible to precompile users subroutines in abaqus using the make
command.
In this way:
I see plenty of sys.exit( 'ERROR: displacement {} not found in the model!'.format(disp))
I would rather create a bunch of compas exception class that could be useful and raise them when needed.
Abaqus, ANSYS and in general all FEA software are units independent.
Remove units from documentation
there is currently no way to use the History Output feature in Abaqus
license information for abaqus is hardcoded in an env file @:
C:\Program Files\Dassault Systemes\SimulationServices\V6R2019x\win_b64\SMA\site\custom_v6.env
Specifying the license type during the analysis in compas_fea won't change the settings.
It is still useful to check if some options are compatible (cpus and user materials).
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.