Git Product home page Git Product logo

compas_fea2's People

Contributors

aryanrezaeirad avatar franaudo avatar gab96mat avatar licini avatar rjodon avatar sam-bouten avatar tomvanmele avatar webermarius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

compas_fea2's Issues

Misplaced import

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

multiple subroutines in Abauqs

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.

Use less dictionary object and create more classes

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

consistent units check

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)

Weird behaviour in UserMaterial.get_constants()

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

Lots of functions need unitary tests

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:

  • be sure that the code is bulletproof.
  • make refactoring and maintenance much easier
  • help to understand what the code does.

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.

Multiline strings formatting

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

Move 'analysis' outside 'Structure'

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.

PEP standards are not respected

I am not PEP8 rigid as some other developers but some stuffs are, let's say more than standard.

  • There is 1 space before and after every signs
  • There is 1 line between class methods, 2 lines between classes, after imports and before if __name__ == "__main__":
  • If you want the code to be clear, don't put more than 1 blank line between code lines, create a visual separator inside a block comment like
#
### 
#
or
#  
# -- Part 1 -------
# 
or whatever 

remove 'launch_job'

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:

  • there is no need to use a python script to send the job. All the information needed can be sent through command line
  • it creates confusion from the development side
  • it requires extra tokes for the license since it calls the abaqus cae module

Heavy things in the code

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__

add more examples in the docstrings

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

precompile user subroutines

it is possible to precompile users subroutines in abaqus using the make command.
In this way:

  1. no need to compile at the beginning of the analyis
  2. no need for common users to install and link compiler

license keyword in abaqus analysis is quite useless

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

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.