MPh-py / MPh

Pythonic scripting interface for Comsol Multiphysics
https://mph.readthedocs.io
MIT License
265 stars 67 forks source link

CPU not exhausted #121

Closed sylvanace closed 1 year ago

sylvanace commented 1 year ago

I noticed that when running the simulation with python, my CPU usage is only like 20 %, but with comsol app it goes up to 80,90%, and the former takes much more time. Is this because I need to run this with the stand-alone mode? Or this is because the feature of python cannot do multi-core?

john-hen commented 1 year ago

Neither. How did you run it?

sylvanace commented 1 year ago

` import mph import re

client = mph.start(cores=1) model=client.load('20230203-SmallRG_EISAppCurve.mph') params={ 'r_ede':['12.5[um]'], 'rg':['3','5','7','10'], 'r_bbl':['2000[um]'], 'glass':['500[um]','1000[um]','2000[um]'] }

for r_ede in params['r_ede']: model.parameter('r_ede',r_ede) for rg in params['rg']: model.parameter('rg',rg) for r_bbl in params['r_bbl']: model.parameter('r_bbl',r_bbl) for glass in params['glass']: model.parameter('l_glass',glass) print(model.parameters()) model.build() model.mesh() model.solve()

model.export('Nyquist',f'20230203-Nyquist-SmallRG-ede({r_ede})-rg({rg})-bbl({r_bbl})-glass({glass}).txt')

            model.export('Bode_real',f'20230203-Bode_Real-SmallRG-ede({r_ede})-rg({rg})-bbl({r_bbl})-glass({glass}.txt')
            model.export('Bode_imag',f'20230203-Bode_Imag-SmallRG-ede({r_ede})-rg({rg})-bbl({r_bbl})-glass({glass}.txt')
            model.export('DisFile',f'20230203-DisFile-SmallRG-ede({r_ede})-rg({rg})-bbl({r_bbl})-glass({glass}.txt')
            model.export('Mesh',f'20230203-Mesh-SmallRG-ede({r_ede})-rg({rg})-bbl({r_bbl})-glass({glass}.png')

`

john-hen commented 1 year ago

But then you told it to use but a single core.

sylvanace commented 1 year ago

you mean:

client = mph.start(cores=1)?

I thought it has something to do with the number of clients, I'll try one with more cores. Thanks!!!