Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Sparse Matrix LU to Decompose and Solve Equations #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

H-Dynamite
Copy link

The use of sparse matrices can greatly improve simulation speed. This sparse matrix and sparse matrix LU decomposition are extracted from the EJML project and can be compatible with the GWT project. We hope to merge them into the project and make a contribution to open source development。

@SEVA77
Copy link
Owner

SEVA77 commented Dec 20, 2023

Maybe that's a good idea. Such global implementations should be offered to the main repository: https://github.com/pfalstad/circuitjs1. Then I would still take this code to this repository.

@pfalstad look at this. Patch for your project: 17.patch.zip

@H-Dynamite
Copy link
Author

Maybe that's a good idea. Such global implementations should be offered to the main repository: https://github.com/pfalstad/circuitjs1. Then I would still take this code to this repository.

@pfalstad look at this. Patch for your project: 17.patch.zip

Well, I tested the performance and it's much faster than before. It can support circuits with at least a few thousand nodes. If this project is used for large-scale circuit simulation, there is still a lot of room for optimization. The main branch of this project was originally this https://github.com/pfalstad/circuitjs1 I always thought it was https://github.com/sharpie7 . Do I need to create another dropdown request for the main warehouse? I'm not very good at playing Git

@pfalstad
Copy link

Wow that sounds great, I’ll definitely take a look! Thanks!

@SEVA77
Copy link
Owner

SEVA77 commented Dec 24, 2023

Wow that sounds great, I’ll definitely take a look! Thanks!

Should li-zhenhai create pull request for your repository?

@pfalstad
Copy link

Yes, that would be easiest for me.

@SEVA77
Copy link
Owner

SEVA77 commented Dec 24, 2023

that would be easiest for me

If you're trying to embed parts of his code in your project, you can just apply my patch:

cat 17.patch | patch -p1

for test this patch:

cat 17.patch | patch -p1 --dry-run

These patches are extracted from any pull requests ("Add .patch or .diff to the end of URLs") but I modified this patch because we have different paths to the source code.

@pfalstad
Copy link

Ok I finally took a look at this and it seems slower, at least on the circuits I tested it on. I tested it with the circuit examples Op Amps->741 Internals and Analog/Digital->QAM-256, and they both seemed a bit slower. Maybe it's only better with some types of circuits, like very large ones? I don't have any circuits with a few thousand nodes to try it on.

@H-Dynamite
Copy link
Author

Analog/Digital->QAM-256 I used the file "Prova8. circuitjs. txt" from the questioner of this issue for testing,For large circuits, use the default step size of 5 μ s. The calculation is slow, even if the step size is adjusted to 500 μ s. Still slow, use sparse matrix and adjust step size to 500 μ s. The performance improvement for large circuits is very obvious, and I may have forgotten to tell you that large circuits need to adjust the step size to 500 μ s. Even larger step sizes can be adjusted according to the size of the circuit,

A set of test results
Refresh Time (Normal LU Decomposition) Refresh Time (Sparse Matrix LU Decomposition) Matrix Size


2167 milliseconds 414.0 milliseconds 1232
7324 milliseconds 532 milliseconds 1592
32102 milliseconds 618 milliseconds 2352
No test 1441 milliseconds 3511

Using a better sparse matrix structure can be faster and support larger matrices. Below are the test results:
Refresh Time (Sparse Matrix LU Decomposition) Matrix Size


400ms 24470/22100
430ms 48870/44200
460ms 73270/66300
550ms 122070/110500

@SEVA77
Copy link
Owner

SEVA77 commented Mar 4, 2024

Well, I can see why making a pull request from the master branch is a bad idea.
@H-Dynamite Transfer your development to a clone of Falstad’s repository but make sure that you create a separate branch for each of your ideas. Mixing your commits that add sparse matrix LU with commits that fix code style into one pull request is a bad idea for me: This will make it much more difficult to add changes from the Falstad’s repository.

It should also be recognized that my repository is not yet suitable for third-party developers. I need to do a lot of work to automate the application build at all stages. Additionally, there will be many other changes on my part, including updating the license to GPL v3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants