-
Notifications
You must be signed in to change notification settings - Fork 70
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
Chat #27
Comments
As mentioned in #16, the next feature release, version 0.9, will be out soon, pending more tests and a few updates to the documentation. As of 0.9, the preferred way to start a local Comsol session is calling
It has always been my goal for release 0.9 to have support for all three platforms. Release 1.0 should follow when operation is proven to be stable and to work in multi-processing mode. That is, when it's clear that separate Python subprocesses can be reliably run from one parent process, so that we can have multiple workers contributing to a single job queue, say for (programmable) parameter sweeps, or even optimization algorithms that can be parallelized, such as the "genetic algorithm". |
I also noticed that I forgot to publish the last bug-fix release 0.8.2 here on GitHub. I'll take care of that at the same time. The release date will be wrong, but the release page here is mainly there for keeping the change-log. Actual release dates are those displayed on PyPI. |
I just uploaded a demo script that has a pool of workers solve a parameter sweep in parallel. It uses the As half-expected, this works without a hitch on Windows, where we run the session with a stand-alone client. But doesn't work on Linux, where we use client-server mode. The problem is the port assignment, as the different server processes get in each other's way as they start up, all trying to grab the same TCP port, 2036. It helps to introduce artificial delays, but that's not only an ugly hack, it would also be a performance hindrance on machines with many cores. |
John, this sounds really cool. Worked out of the box on Catalina and I excited to test all the features. Congrats on the initiative! |
Thanks, Gustavo, glad to hear! Feel free to post feedback and questions here as you go along. |
Status update... The |
I think I do have two more things to throw in the ring:
|
First of all, sure, there can be more things. Release 1.0 would take us out of beta and into production/stable territory, so I'm all for waiting a bit longer before pulling the trigger. Could be that our tests will reveal more bugs to fix, which would be a good thing.
|
Regarding
|
I looked at this the other day and wasn't sure if we want to have this new argument |
I just released 0.9.1 with the latest changes that were in |
FYI, I've removed the |
I've renamed the |
We're getting closer to release 1.0. I'm planning to then get a DOI from Zenodo in case anyone ever wants to cite MPh in a paper. So testing, more than anything else, is the order of business until that release. By the way, the docs at mph.readthedocs.io always point to the stable release, which is 0.9.1 at this point. But the latest version, i.e. the development version in |
I will do just that the next days. Got some COMSOL on my table anyway.
Please do that. I work in Academia and many around me use COMSOL and are not happy with the scripting, so there will some users I guess. I will obviously spread the 1.0 word |
If you find bugs with the latest additions, you can just report them here in chat or in the other issue. No need to track them separately if they don't concern a past release. One thing I already know: The wheel doesn't build at the moment. That's because I put an α in the version number, which
Not just in academia. I think the first bullet point in the release notes will be some variation of: "We now offer you the best API Comsol has ever seen! 🎉" |
Hello, First, thanks for making this great API. I was very excited and this should help with some coupled modelling I hope to do. I have been struggling with evaluating my results however. I am running a PEMFC simulation very similar to this one One of the key results, current, is acquired via a volume integration however, as far as I know I can only extract the local current per volume relative to x, y, and z coordinates. I think I can find the integrated value by summing the local current per volume multiplied by the element the current per volume is assigned to, however it is quite difficulty to pin-point exactly which elements correspond to which current. This is particularly difficult since I think the points align with element boundaries rather than say the centre of the elements. If I go with this method is there a way to extract the mesh information (volume of each element, indices of element boundaries etc.? The best thing for me would be if there is a way to access table values created within COMSOL. Is that possible through this API? Otherwise do you have any other method I could try to get the value I'm after? Please let me know if you need any more info. Any insight into this would be greatly appreciated! Cheers, Eric |
Eric, let me try to help you here: In general, the evaluate functionality is not that mature. There are few dataset types that are supported - I guess yours is not as we focused on editing and adding model features as you can see from the issues. Currently, I see a few possibilites:
As soon as nodes are working safely (Release At last - if its not confidential - feel free to upload a stripped model and let me know what you need in more detail |
Hi Eric, I'm glad you like the API. It will only get better in the upcoming release. As Max explained, MPh does not replicate the entire Comsol API. Tables, for example, are not covered by MPh, and neither are certain results types, such as "volume integration" (accessible under "Derived Values" in the GUI). But if push comes to shove, you can always access the Comsol API directly, from Python, see section "Creating models" in the documentation. I don't think that's necessary in this case. First of all, you should certainly let Comsol do the volume integration. Comsol knows its finite elements better than any of us, no need to try and recreate that in Python. What I would do here, I would define an integration coupling operator (under Definitions→Variables near the top of the model tree) and then use that in a global evaluation in post-processing. Global evaluations are supported by MPh, you can just pass the same expression to Generally, this is the recommended way to automate post-processing: You define what you need in the model itself and then just trigger the evaluation or export via MPh. |
HI Max and John, Thank you both for the quick replies! As I was figuring out how to do John's solution, I realized I already had global evaluations in the form of a domain probe and that's how I was getting my results in COMSOL in the first place. I just did not realize the results of the evaluations had expressions I could call with model.evaluation(). Thanks again! I look forward to new releases and hope to cite this API in a paper at some point! Cheers, Eric |
Also with the 1.0 release, I'm planning to move the repository to the GitHub "organization" MPh-py, which I've just created for that very purpose. Mostly to have shorter/nicer URLs when linking to the repo. I don't think we need the organization features. But lots of other projects use such a structure, JPype for example, so I figure this can't be wrong. I hope all existing URLs will be redirected, as the GitHub documentation promises, so that old documentation builds of MPh don't suddenly link to dead targets when referring to the GitHub repo. Forks will automatically point to the new location and issues will be transferred. Only local clones may need to be reconfigured to push to the new I will hold off on that until the release is final, because the meta information on PyPI would also need updating, and that can only happen when a release is published. |
Hi all, I thought I would share a new function that I adapted from the evaluate code: ` def interp(self, expression, coord=None, unit=None, dataset=None,
With this I was able to pass co-ordinates where I want some field values. An example call might be: ` x = np.linspace((0.12 / xy_points) / 2, 0.12 - (0.12 / xy_points) / 2, xy_points)
` This has worked a treat for me. |
Thanks for sharing, Joel. It will have to wait until after release 1.0, which is imminent. But we'll get to that eventually. See also feature request #26. |
Release 1.0 is out now. 🎉 Thanks a lot for all your help, Max! The new features we discussed in #25 turned out much better than I had ever hoped they would. My original plan was just to be stable on all three platforms by 1.0. But this deserves the version bump even more. Cheers. 🥂 |
Thank you for the work you put in the project. Let's see how the new features work out and how much is reported back. I will presumably use it myself in the coming weeks, quite a lot. |
Hello, I have updated mph from version 0.8 to 1.0. It seems that if I use the model.parameter function with a complex value, it truncates the imaginary part in the newer version. Can you please advise what to do? |
Hi, thanks for bringing this up. I've never tested complex values, but could easily add that to the test suite. Can you please open a new issue and provide a code example? Just the call to |
John, I have seen you keep on improving the current setup, nice work. I hope you haven't had to type the tags json by hand 🙃. |
Oh, come on, like you owe us an apology. This project here wouldn't exist without JPype. I am, quite frankly, in awe how complicated it is to get Python and Java to play nice with each other. It's ready when it's ready and we'll wait. Plan is to have one more bug-fix release (1.0.5) in the 1.0 series, which will require JPype |
Just dropping by to say thanks for this project. I was using pyautogui to automatically script COMSOL before I found this, and this is so easy to use in comparson. I plan to cite MPh in future work, so please let me know if you get a DOI! |
Thanks, glad to hear it. I can see how this is a step up from PyAutoGui, that's probably quite a fickle setup. Never even considered that, even though I suffered the shortcomings of the Matlab interface (or just Matlab, really) for several years and desperately wanted to move to Python. This only works thanks to JPype, bears repeating. You find the DOI at the bottom of the project's front page, either here on GitHub, or on Read-the-Docs, or PyPI. It's just a "badge", not mentioned in the text, and links to the corresponding Zenodo page. Which is a service provided by CERN, for any kind of software, and let's you cite specific versions or the project as a whole. That's pretty much the extent of what I know about it. |
I tried this package and I'd say this is just awesome, GOOD JOB. Is that possible that we can build up some inter-process communication(like sockets) as a COMSOL application builder method? |
Thank you for the compliment. As for your use case, I'm not sure I follow. When you say "compiled model", do you mean you have a stand-alone application produced by the Comsol Compiler? If so, there is almost certainly nothing we can do. As that should be a monolithic executable that, probably by design, won't interact with external processes. But maybe you mean a compiled Java model, produced with |
Thanks for the promote reply. I'm trying to send data from python to java. By compiled model, I mean here at 1:06. The main reason for this approach is that you don't need the license for the compiled model, you can run it wherever you want. To be honest, I do get confused about the java model produced by comsolcompile and the one I showed above. |
You can save a So you want to exchange JSON data with that compiled application. MPh won't be of any help there. And neither will be JPype, the underlying Java bridge. But your idea might still work if you figure out how to set up that TCP socket connection on both sides. Because that's language-agnostic. The Python side won't be the problem, you can just use the |
Yes, you understand my ideas. Anyway, thanks for helping, i might just give up this idea and stick to your package. Thanks again for providing this awesome package! |
@John-Hennig BTW |
Yeah, I know. My tests with the final release were however not as successful as with the development version. Otherwise I would have already published 1.0.5 a week ago. So I'm a little bit stuck. I'll try to consolidate my local copy of the |
Please let me know if the shutdown fix didn't work. I removed one of the options as it was found to violate the JVM mechanics (you can't unload the JVM dll or the interrupt handlers will become unstable.) But otherwise, it should be exactly as we discussed. |
@Thrameos Will do, thanks. I'll report details in issue #38, later this week, but I'll ping. I need some more time to rerun the tests with the dev version vs. the new version. There's also the added complication of pyTest turning on fault handlers during shutdown, which (also) leads to seg faults on Windows, so I'm trying to find out what's what. |
Any news on the jpype improvement? Any way I can support? |
Wasn't the shutdown issue resolved with 1.3.0? Or is there further action required? |
From ‘jpype‘ it was but the old workaround is still in here and @John-Hennig mentioned some issues left however up to now no update has been finalized so that’s why I asked. |
So I tested with @Thrameos I have the log below sorry its quite long Error:
Log: https://gist.github.com/max3-2/dd0c6612df0660a65e99a5960a9fdc1c |
If we could replicate the situation it would be great. I am guessing that the test is creating a thread which was in a bad state at the time the shutdown and needs to be terminated before the shutdown call. But that is only a guess.
Nothing in the error log stood out for me in the first glance. I will look it over more when I have some additional time.
|
The only thing I see different is that in this test (test_client) a model is loaded from file and not created which is a little more data IO. However, changing that to a model created on the fly did not really made a difference. Im still a little confused why this specific test is causing issues and I will report back... FWIW I patchen in a if not jpype.config.destroy_jvm:
print('zZZz')
time.sleep(1.) at ll341 jpype._core and this makes the issue much less likely to pop up - maybe some thread needs more time to shut down if destroy_jvm is disabled? Edit: OK I traced it down to |
I was wondering if COMSOL bough you out... ;) Ill continue in #38 think thats the correct place to discuss.. |
Hi John, first of all, kudos for the awesome job on this. the problem I'm currently facing is that running on a Ubuntu machine I'm able to start a client, load a model, solve but then when I try to use the model.export I get the following: any idea? I have to say that the same code and model run just fine on my mac machine. |
Just a follow up just in case someone runs into the same issue. |
Hi, @smick290. Thanks for sharing. I was not aware of this issue, but it seems you have found a solution. I do test on Ubuntu (in a VM), but never via ssh. We do start the Comsol server process with the It would be possible to make the |
I've been unable to scale my use of MPh to use other computers.
Which gives me
Is there something obvious that you can see that I'm doing wrong? ============== edit: port needs to be an int not a string. |
I see you figured it out. Yeah, we're interfacing with Java, and as a strongly typed language, it is less forgiving than Python when it comes to type mismatches. |
Unpinned as it distracts from the open issues, and closed as we now have Discussions for general feedback. |
Leave a comment here if you have general feedback, a question to ask, want to float an idea, share a user story, or have anything else to say that may not merit opening a new issue.
Please do not leave a comment here if you are reporting a bug. Then by all means do open a new issue.
The text was updated successfully, but these errors were encountered: