Creating Replaceable models - modelica

I wanted to know if Modelica allows us to create replaceable models?
I was trying to redeclare the Modelica.Blocks.Sources.Constant to a block which goves constant voltage. I only need to change the unit of the variable k. (from nothing to "Volts").
Is it possible to do this in openmodelica?

You don't need replaceable model for that.
Just use a modifier on the Modelica.Blocks.Sources.Constant component:
Modelica.Blocks.Sources.Constant const(k(unit = "V"));
But to answer your question, yes OpenModelica supports replaceable models.

The topic of replaceable components is discussed in the chapter on architectures in my online book, "Modelica by Example". You might find it useful.

Related

Clustering with nonlinear mixed effect modeling

I want to optimally find the clusters and assignment of each subject into the correct cohort in the nonlinear mixed effect framework. I came to know a package in R which is lcmm that calls this type of modeling a latent class mixture model. They have the clustering of the linear mixed effect model in hlme function. I am wondering if there is a package that deals with the latent class/clustering of the nonlinear mixed effect modeling? Any help is appreciated.

Nozzle - Modelica

I want to model and simulate a hydraulic system in Modelica. In this system I have a nozzle. I want to include the nozzle in Modelica. But I cant find a suitable component in Modelica which represents the nozzle. Do you have an idea if there is a nozzle component in Modelica library ?
Try the package Modelica.Fluid.Valves. In particular, the model Modelica.Fluid.Valves.ValveVaporizing could be what you are looking for.

How to specify medium in Openmodelica?

I am simulating a heat pump water heating system in Modelica. I have attached the picture of my model. However, when I run the model I get the error "Medium is partial, name lookup is not allowed in partial classes". Can you please let me know:
How should I specify the water in tank, heat pump condenser and pipe?
How should I specify air in heat pump evaporator?
And in general, I did not find any example of modeling thermal systems in Openmodelica, can you suggest a source?
Thanks

Issues with the "Chattering" example in Chapter 2 of Modelica by example

Here is the link of the model:https://mbe.modelica.university/behavior/discrete/decay/#chattering
The simulation result for the following result in Dymola 2021 would be:
model WithChatter(stopTime=1.001s)
model WithChatter(stopTime=1.5s)
As we could see, noEvent operator does decrease the CPUTime, but it also causes the system stiff, it would be easier to understand with more explanation about why noEvent would cause the system stiff.
Based on the event logging of model WithChatter, the simulation process actually uses the minimum time step because the der(x) is not a continuous function. But why doesn't this approach suit the model WithNoEvents?(https://mbe.modelica.university/behavior/discrete/decay/#speed-vs-accuracy)
If noEvent operator means using the integrator directly, it might require the functions in the equation system have to be continuous? So Does this mean that the model used in the Chattering example(https://mbe.modelica.university/behavior/discrete/decay/#chattering) isn't appropriate, since the function in this model is not continuous?
The model used in the chattering example isn't appropriate since it is not continuous, and the error message from dassl is just a boiler-plate message, so the model isn't stiff but discontinuous as you found.
Markus A has a good point in the related question When to use noEvent operator in Modelica language? that using noEvent to avoid chattering is in general not a good idea, and one should normally try to rewrite the model instead of adding noEvent.
This specific model is sort of similar to a friction model where you would have
der(v)=(if v>=0 then -1 else 1)+f_other/m;
The solution for friction is not to introduce noEvent, but to add a stuck mode as in Modelica.Mechanics.Rotational.Components.BearingFriction.

Cross Entropy for Language modelling

im currently working on a classification task using language modelling. The first part of the project involved using n-gram language models to classify documents using c5.0. The final part of the project requires me to use cross entropy to model each class and classify test cases against these models.
Does anyone have have experience in using cross entropy, or links to information about how to use a cross entropy model for sampling data? Any information at all would be great! Thanks
You can get theoretic background on using cross-entropy with language models on various textbooks, e.g. "Speech and language processing" by Jurafsky & Martin, pages 116-118 in the 2nd edition.
As to concrete usage, in most language modeling tools the cross-entropy is not directly measured, but the 'Perplexity', which is the exp of the cross-entropy. The perplexity, in turn, can be used to classify documents. see, e.g. the documentation for the command 'evallm' in SLM, the Carnegie-Melon university language modeling tools (http://www.speech.cs.cmu.edu/SLM/toolkit_documentation.html)
good luck :)