I want to do local senstivity analysis in Dymola to evaluate different parameters affecting the energy consumption in a building (for multi-familyhouse).
Can anyone give me some suggestions, how to do it in Dymola (Modelica) software?
You could export you model as FMU and then follow one of many the different paths for sensitivity analysis with FMUs:
PyFMI + SAlib Sensitivity Analysis using PyFMI - FMU in for-loop
FMI Toolbox for Excel by Modelon http://www.modelon.com/products/modelon-deployment-suite/fmi-add-in-for-excel/
openTURNS + FMI https://www.researchgate.net/publication/321624302_A_Probabilistic_take_on_system_modeling_with_Modelica_and_Python, https://github.com/openturns/otfmi, http://www.openturns.org/
...
Did you take a look at the "Design" library that comes with Dymola? It contains functions to sweep and perturb parameters.
You can load it in File -> Libraries -> Design. Some examples on how to apply the library can be found in the first chapers of the Dymola Manual 2. From the question I guess the Calibration package should be most useful for you.
One approach could be to do the modelling in Dymola (or OpenModelica, Simulation X, whatever), and then do the parameter sweep, pre- and post-processing, plotting, optimization and so on from Python. Dymola has a Python interface, so you can start simulation, read results, change parameters and so on from Python. Everything that can be done from the GUI is in theory also possible from the Python interface.
A Matlab interface and a Javascript interface are also available.
Related
I was trying to compare the performance of a microgrid between Simulink and Openmodelica. The microgrid has different VSC converters working in EMT average, synchronous generators, loads, lines and buses and the model obtains quite logical results, the problem is that when the same model is created with OpenModelica, the following error is obtained with DASSL solver and a step size of 2e-5 s:enter image description here . Also, the libraries used are Dynawo and the standard Modelica library. Does anybody knows what this error means and how can it be solved? If anybody wants to see the models or needs more information I could send it.
Thanks!
I tried to simplify the model the much as possible, using simple control techniques for the VSCs (no droops or LVRT) in Simulink and Modelica and I confirmed that the same values are used in both models. Also, I changed the tolerance, the step size and the solver.
I am currently trying to use Simscape to design and simulate the electrical circuit and COMSOL Multiphysics to simulate the electromagnetic interaction between coils. What I'm not certain of is whether or not we can successfully link the two software packages nicely via MATLAB or not. They both have MATLAB support though.
I am also researching whether ANSYS suite. There may be some software we can use that would take the place of one or both of the previous software.
Several years ago I had to make a connection between COMSOL and Matlab as well. This is called a Matlab Comsol LiveLink.
However, I think (not sure), that the electrical circuit should be modeled in COMSOL. Using the LiveLink you can set parameters in COMSOL using Matlab and extract the updated calculation. To my knowledge you cannot input a model, do calculations, and then extract the results.
You can look in the users guide, maybe it says something about this
Some other links which may be useful:
LiveLink™ for MATLAB®
Integrate COMSOL Multiphysics® with
MATLAB® Scripting
I have simmechanics model in simscape, I have imported it from solidworks design
I'm able to get linearized model using linmod and it is okay as any system in simulink
The problem here that I want to get the differential equations for that system, Is there any way to extract them?
The short answer: no, there is no built-in functionality.
The long answer: you'd have to parse the Simscape network, query the source equations (if the source code is visible). And stack these together. That's a pretty involved workflow.
I have a large simulink model with many source and sink blocks, many with only elementary arithmetic operations in between. I have been asked to document the equations behind the model. I am currently doing this manually and I am finding it rather slow and there is a relatively high chance of errors in the process.
Is there any way for Simulink to generate the equations (in MATLAB syntax for example) automatically?
There is no utility in MATLAB/Simulink that can do exactly what you are looking for (and I personally don't know of any third-party tools that can do this, either).
However, I think that your best bet might be to make use of Simulink Coder. This will allow you to convert your Simulink model to C code. From that code, you may be able to extract the equivalent equations more easily than you can by analyzing the Simulink model by hand.
The catch, though, is that Simulink Coder is an add-on package to base Simulink, so you may or may not have this tool available to you.
I am trying to do some text classification with SVMs in MATLAB and really would to know if MATLAB has any methods for feature selection(Chi Sq.,MI,....), For the reason that I wan to try various methods and keeping the best method, I don't have time to implement all of them. That's why I am looking for such methods in MATLAB.Does any one know?
svmtrain
MATLAB has other utilities for classification like cluster analysis, random forests, etc.
If you don't have the required toolbox for svmtrain, I recommend LIBSVM. It's free and I've used it a lot with good results.
The Statistics Toolbox has sequentialfs. See also the documentation on feature selection.
A similar approach is dimensionality reduction. In MATLAB you can easily perform PCA or Factor analysis.
Alternatively you can take a wrapper approach to feature selection. You would search through the space of features by taking a subset of features each time, and evaluating that subset using any classification algorithm you decide (LDA, Decision tree, SVM, ..). You can do this as an exhaustively or using some kind of heuristic to guide the search (greedy, GA, SA, ..)
If you have access to the Bioinformatics Toolbox, it has a randfeatures function that does a similar thing. There's even a couple of cool demos of actual use cases.
May be this might help:
There are two ways of selecting the features in the classification:
Using fselect.py from libsvm tool directory (http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/#feature_selection_tool)
Using sequentialfs from statistics toolbox.
I would recommend using fselect.py as it provides more options - like automatic grid search for optimum parameters (using grid.py). It also provides an F-score based on the discrimination ability of the features (see http://www.csie.ntu.edu.tw/~cjlin/papers/features.pdf for details of F-score).
Since fselect.py is written in python, either you can use python interface or as I prefer, use matlab to perform a system call to python:
system('python fselect.py <training file name>')
Its important that you have python installed, libsvm compiled (and you are in the tools directory of libsvm which has grid.py and other files).
It is necessary to have the training file in libsvm format (sparse format). You can do that by using sparse function in matlab and then libsvmwrite.
xtrain_sparse = sparse(xtrain)
libsvmwrite('filename.txt',ytrain,xtrain_sparse)
Hope this helps.
For sequentialfs with libsvm, you can see this post:
Features selection with sequentialfs with libsvm