Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2012年3月27日 GMT-4 02:41
What I usually do in a case such as yours, is:
* Start with the full model or the simpler example model.
* Load it in the Comsol GUI.
* Reset history (from the File menu).
* Make the modification of interest, such as reassigning the boundary conditions in your case.
* Save the model as Model M-File (from the File menu).
The API commands pertaining to the modifcation of interest are then the last one(s) in the resulting .m file. It's usually rather straightforward to generalize those commands to apply to all other cases as well. It may help, though, to define the appropriate selections in the Comsol model first.
Eventually, the Matlab loop will be quite short:
* Load the original Comsol model using model = mphload('filename.mph').
* Apply the modifications to the (Matlab) model object as examplified by the .m file.
* If the geometry was changed (not the case in your example), re-analyze geometry (model.geom('geom1').run) and re-mesh (model.mesh('mesh1').run).
* Run the simulation (model.sol('sol1').runAll).
* Postprocess (mpheval, mphint, etc.) or save the model to disk (mphsave).
* Continue to loop through the other cases.
Tags such as "sol1" for the study or "mesh1" may be different in any given model.
Note that in your case it may be sufficient to run a "port scan" (see the AC/DC module's documentation), completely within the Comsol GUI without the need for Matlab scripting.
What I usually do in a case such as yours, is:
* Start with the full model or the simpler example model.
* Load it in the Comsol GUI.
* Reset history (from the File menu).
* Make the modification of interest, such as reassigning the boundary conditions in your case.
* Save the model as Model M-File (from the File menu).
The API commands pertaining to the modifcation of interest are then the last one(s) in the resulting .m file. It's usually rather straightforward to generalize those commands to apply to all other cases as well. It may help, though, to define the appropriate selections in the Comsol model first.
Eventually, the Matlab loop will be quite short:
* Load the original Comsol model using model = mphload('filename.mph').
* Apply the modifications to the (Matlab) model object as examplified by the .m file.
* If the geometry was changed (not the case in your example), re-analyze geometry (model.geom('geom1').run) and re-mesh (model.mesh('mesh1').run).
* Run the simulation (model.sol('sol1').runAll).
* Postprocess (mpheval, mphint, etc.) or save the model to disk (mphsave).
* Continue to loop through the other cases.
Tags such as "sol1" for the study or "mesh1" may be different in any given model.
Note that in your case it may be sufficient to run a "port scan" (see the AC/DC module's documentation), completely within the Comsol GUI without the need for Matlab scripting.
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2012年3月28日 GMT-4 03:11
Thank you very much for the detailed response!
Could you elaborate a little more on the "port scan?" I tried to search in my COMSOL documentation and online, but the closest function I found was "port sweep" in the EM Waves Interface, about which I am not sure how to perform the tasks I desire...
Thank you very much for the detailed response!
Could you elaborate a little more on the "port scan?" I tried to search in my COMSOL documentation and online, but the closest function I found was "port sweep" in the EM Waves Interface, about which I am not sure how to perform the tasks I desire...
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2012年3月28日 GMT-4 03:24
You're right, "port sweep" is the key word, not port scan. I remembered it wrong. It's described in the AC/DC module's documentation. The purpose of a port sweep is to determine "lumped parameters" such as the capacitance matrix. Basically, how it works is: you define several electrodes (ports/terminals) and then run a parametric sweep where in each run only one port is at a given potential (say 10 V), while all the other ones are on ground. This is similar to what you described above, which is why I suggested you look into it.
You're right, "port sweep" is the key word, not port scan. I remembered it wrong. It's described in the AC/DC module's documentation. The purpose of a port sweep is to determine "lumped parameters" such as the capacitance matrix. Basically, how it works is: you define several electrodes (ports/terminals) and then run a parametric sweep where in each run only one port is at a given potential (say 10 V), while all the other ones are on ground. This is similar to what you described above, which is why I suggested you look into it.
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2012年4月2日 GMT-4 06:13
hi I could not get the parametric sweep to do what I wanted, but the save as M-model really simplifies the process, thanks a lot.
however, does it ever happen to you that you get different solution result running in matlab than running in comsol?
i first ran one case in comsol, export the data. then saved the exact same file to a .m, and in matlab console ran it again. i literarily got somewhat similar but different data set...
if it were minor differences i would not even bother, but than it occurs when in comsol it gave me the solution very quickly, in matlab it complains about "divergence of linear iterations."
hi I could not get the parametric sweep to do what I wanted, but the save as M-model really simplifies the process, thanks a lot.
however, does it ever happen to you that you get different solution result running in matlab than running in comsol?
i first ran one case in comsol, export the data. then saved the exact same file to a .m, and in matlab console ran it again. i literarily got somewhat similar but different data set...
if it were minor differences i would not even bother, but than it occurs when in comsol it gave me the solution very quickly, in matlab it complains about "divergence of linear iterations."