Skip to content

Jacobian Matrix in multi-lump MDNR method #102

@pablomarcos02

Description

@pablomarcos02

Hello, I was trying to implement a multi-lump model for the compressor I am simulating and the results I was getting were not making any sense, so I started looking in depth in the code for the Newton-Raphson method for the convergence of the temperature in the lumps, and checking everything with prints I found out what I think is a mistake on the calculation of the Jacobian:

for jj in range(len(self.Tlumps)):
                        delta = np.zeros_like(x)
                        delta[jj] = dx[jj]
                        self.Tlumps = self.Tlumps + delta
                        ri = self.callbacks.lumps_energy_balance_callback()
                        #print('ri:',ri)
                        ri = np.array(ri)
                        J[:,jj] = (ri-r0)/delta[jj]

You are adding delta to self.Tlumps, so in the first lump, the derivatives are right, but in the following ones you are not computing actual partial derivatives, as delta is added to the lump whose column in the jacobian is being calculated but is also added to all the previous ones because self.Tlumps does not reset to x at the end of the block.

What I changed is instead of doing:
self.Tlumps = self.Tlumps + delta
Doing:
self.Tlumps = x + delta
And my results started making sense.

I'm not entirely sure that I'm right as I'm fairly new on python, so I'm sorry if I'm wasting your time, but I think it is worth checking :)
Thanks for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions