topopt icon indicating copy to clipboard operation
topopt copied to clipboard

Plotting of Compliance: Force arrow in wrong direction.

Open gillhofer opened this issue 5 years ago • 4 comments

Either my understanding of physics of wrong, or the force along the x-direction is wrongly visualized.

I would expect the image below is optimal if the horizontal force is pointing in the other direction.

0442

gillhofer avatar May 15 '19 13:05 gillhofer

Thanks for reporting this issue. There seems to be a bug in the plotting of EITHER the horizontal force or the vertical one. If I remember correctly a negative y-force should point upward. Its (probably) solved by removing the negative sign from the following line: https://github.com/AJJLagerweij/topopt/blob/1ad20e0bf961301ebca7a07205d02a51b7827196/src_Compliance/plotting.py#L132-L133 I can have a look at it this Saturday and update the git.

Regards, Bram

AJJLagerweij avatar May 16 '19 16:05 AJJLagerweij

Thank you. The solution looks reasonable by changing the sign in https://github.com/AJJLagerweij/topopt/blob/1ad20e0bf961301ebca7a07205d02a51b7827196/src_Compliance/plotting.py#L124-L125

Keep up the good work.

gillhofer avatar May 17 '19 06:05 gillhofer

Hello Gillhofer,

I see why your solution would solve the problem. I want to verify that it is working, for this purpose I've been trying to recreate the problem. I was not able to do so yet.

I've plotted the displacement fields of the cantilever beam example. y_load and displacement x_load and displacement In both cases the load direction seems to coincide with the displacement direction. But I agree that the plot you obtained is incorrect, could you share your load class?

Regards, Bram

AJJLagerweij avatar May 18 '19 13:05 AJJLagerweij

It is not exactly the same but very similar. The result of the optimization process looks sane if I change the sign like discribed above. It is meant to work with a 128x128 grid.

class Issue1_Load(Load):

    def __init__(self, nelx, nely, young, Emin, poisson):
        super().__init__(nelx, nely, young, Emin, poisson)

    def force(self):
     
        f : 1-D array length covering all degrees of freedom
            A -1 is placed at the index of the y direction of the top left node.
        """
        f = super().force().reshape([self.nelx + 1, self.nely + 1, 2])
        f[70, 30, 0] = -1
        f[10,10,1] = -1.0
        return f.reshape(-1)

    def nodeid_from_coords(self, x, y):
        # first id is the node id for the fixdos in x, second for y.
        return [x * (self.nely + 1) * self.dim + self.dim * y,
                x * (self.nely + 1) * self.dim + self.dim * y + 1]

    def fixdofs(self):
        return [node for i in range(0, self.nelx) for node in self.nodeid_from_coords(i, self.nelx)]

gillhofer avatar May 20 '19 07:05 gillhofer