Modelica : Simulation of temperature rise in a cable - How to do? - simulation

I am a beginner on modelica. I wanted to transpose a model found on a paper (on internet) to a modelica model.
Here is the paper :
Insulated Cable Temperature Calculation and Numerical Simulation
I am stuck in rewritting the fomulas. Second derivative on a variable different of time --> i don't know how to do.
Another way I was thinking is to use the Thermal/HeatTransfer library. But here too, I don't know how to put the blocks togethers... I think this is due to a big lack in thermodynamic knowledge from my side.
--> I don't know what block to use to simulate the conductor and the insulation layer.
Maybe this is something too difficult ?
If someone has an idea on how to start, it will be a pleasure to read you :)
I tried to use the Thermal library :
Using heat transfert lib.
I have a current source and a resistance.
The resistance will change depending on the temperature involved by the current in the resistance.
I use 0.004 as alpha for the relationship R=R20*(1+alpha(T-Tamb)).
Let's say I have a 1 meter copper conductor with a crossSection of S=16mm² = 15.10^-6m²
then the initial resistance is R = rho.L/S ≃ 1.07mΩ at 20°C
Following this example of cable : Bayka 16mm²
To get 70°C at the surface of the conductor, then the max current for a single 16mm² wire cable is 107A in air, and 160A in earth.
I took, in my example, random value of thermal conductance and capacity to get an approximative temperature near the one given in the table (~70°C).
Is this model is the good one for an insulated cable ? (no considering values)
Or I forgot something? Maybe I am wrong in the position of the blocks ?
What do you think ?

Looks reasonable to me, might be easier to use the same component for heat conduction (heat resistor or heat conductance, not both) in order to be able to compare the two values. The mathematical formulas for radial heat conduction can be found here e.g. https://web2.clarkson.edu/projects/subramanian/ch330/notes/Conduction%20in%20the%20Cylindrical%20Geometry.pdf

Related

Simscape Physical Signal: Why does is exist?

What is the added value of simscape physical signals compared to normal simulink signals? As far as I can see, from a functional perspective there is no difference between the two types of signals: I can add units to both types, they both have a direction of flow, and they both have similar function blocks like adding, substracting... Only for physical signals the available types of blocks is very limited. Why didn't the matlab guys just use normal simulink lines instead of the physical signals?
Physical signals, unlike Simulink signals, have units associated with them. This means that they follow a number of rules, for example to ensure that the right unit is used (e.g. you can't add kg and m/s). From the documentation:
Using the Physical Signal Ports
The following rules apply to Physical Signal ports:
You can connect Physical Signal ports to other Physical Signal ports with regular connection lines, similar to Simulink signal
connections. These connection lines carry physical signals between
Simscape blocks.
You can connect Physical Signal ports to Simulink ports through special converter blocks. Use the Simulink-PS Converter block to
connect Simulink outports to Physical Signal inports. Use the
PS-Simulink Converter block to connect Physical Signal outports to
Simulink inports.
Physical Signals can have units associated with them. Simscape block dialogs let you specify the units along with the parameter
values, where appropriate. Use the converter blocks to associate units
with an input signal and to specify the desired output signal units.
Any sensor block in Simscape (in whatever physical domain) will output a physical signal. You can then convert it into a normal Simulink for feed to your controller. Similarly, any source block in Simscape (in whatever physical domain) will take a physical signal as input.
I suggest you just read the Simscape product page
In particular,
Simscape components represent physical elements, such as pumps, motors, and op-amps. Lines in your model that connect these components correspond to physical connections in the real system that transmit power.
Accompanying that description is the following image, which shows how Simscape models can be far more intuitive to build than a model which uses standard signal. This means models are far more maintainable and clearer to, for example, engineers who may not have a comp-sci background.
Let's delve into what a "physical connection" is somewhat.
[Simscape] employs the Physical Network approach, which differs from the standard Simulink modeling approach and is particularly suited to simulating systems that consist of real physical components.
[ ... ]
Each system is represented as consisting of functional elements that interact with each other by exchanging energy through their ports.
You stated in your question that both methods have a flow direction. This is wrong!
Simscape blocks try and balance the energy between the inlet(s) and outlet(s). For instance a fixed orifice in a fluid system may have high pressure on one side. Simscape will try and solve the pressure balance each iteration. You would need some custom Simulink subsystem to achieve this if not for Simscape.
What is the added value of simscape physical signals compared to normal simulink signals?
What is it that you think Simscape physical signals provide? Is it one number? How do you solve a mass-spring-damper system with just position? It's position AND it's speed AND it's acceleration.
I can add units to both types
No you can't. You put whatever you want in Simulink. You don't get to choose anything about what's in the physical signal in Simscape. You can specify units in the blocks that the signals connect, but you don't get to pick what the pipe itself is carrying.
they both have a direction of flow
No they don't. Your head and your torso are connected. There's no directionality to this. They're just connected. The physical signal is likewise just showing that (things) are physically connected. Again, the mass-spring-damper system: If the damper points to the mass, and the spring points to the mass, then is there any possibility that the damper could affect the spring? Yes, of course. The damper affects the spring because the damper affects the mass and the mass affects the spring.
The spring affects the mass, and the mass affects the spring. The signal is bidirectional. You're confusing signal directionality with kinematic chains.
they both have similar function blocks like adding, substracting
If you're on a train that's going 30 mph, and you're walking forward at 3 mph, how fast are you going relative to the world frame? What if you're walking backward? There is a physical meaning in adding and subtracting physical signals.
[For] physical signals the available types of [function blocks are] very limited
What is it that you're thinking they're missing? Can you also provide a description of what the physical meaning of that function block would be?
Why didn't the matlab guys just use normal simulink lines instead of the physical signals?
Because they're not the same. The biggest point is probably that Simscape is signal + derivative + second derivative, but again they're just conceptually different. Simulink is an easy way to write code - do this step, move along the arrow, do the next step, etc. Simscape is a pictorial representation of a physical system. The physical signal lines just show that things are connected. The system gets solved simultaneously.
I don't think it's mainly about the enforcement of physical signal units, nice though this is.
I think it's about the solver - and before it gets to the solver, about the choice of states and equation causality - rearranging the equations ready to be solved.
Simulink doesn't have any truck with this and just gets straight on with integrating signals as a succession of samples. I know it gets complicated with variable step solvers, but they are only doing extra fancy numerical analysis with the sampled data. Integration and the here-and-now is what it's all about!
Simscape just starts with a bucket of variables and a bucket of equations that variously depend on said variables. A 'bipartite graph', I believe they call it.
Just as we have to navigate a route through simultaneous equations to pick off the simple ones and substitute (or the matrix equivalents of this) Simscape has to do likewise in software so wants to keep alive augmented info on signals like which equations they are in and whether it knows or can easily obtain their derivatives, what they are, etc. Physical signals behave for us users just like Simulink signals, but I reckon they are there to provide the valuable service to Simscape of keeping this augmented info alive and linked between blocks so that one massive matrix equation can be formed for the whole system, not separate ones that get sampled as Simulink systems between Simulink blocks.
This rearrangement of equations ready for the more conventional solver getting stuck in is a black art indeed! We learn very little of how Simscape does it from the MathWorks docs, but you can install OpenModelica for free and see how that does it.

modeling an relationship between sensor values and position (angle and distance) to a target

I want to derive a simple model that can predict a current position of an object with respect of a target.
To be more specific, I have a head that has 4 identical light sensors placed between 90 degree. There is a light source (LED) emitting visual light. Since each sensor has angle spectrum (maximum at 90 degree and decrease its sensitivity while the angle of the incident of light increases), the receiving value at each sensor is determined by the angle and distance of the head with respect of the target.
I measured the values at four sensors at various angles and distances.
Each sensor has maximum values around 9.5 when incoming light is low (either the sensor is far from the target or the sensor faces away the target), while the value decreases as the sensor gets close to the target or faces directly toward to the target.
my inputs and outputs look like
[0.1234 0.0124 8.342 9.232] = [angle, distance]: an example of the head placed toward next to the light.
four inputs from the sensors and two outputs for the angle and distance.
What strategy can I implement to derive an equation that I can use for predicting the angle and distance by putting current incoming sensor values?
I was thinking of multivariate regression, but my outputs are not a single scalar (more of vectors). I am not sure it will work.
Therefore, I am writing here for asking some help.
Any help would be appreciated.
Thanks
Your idea about multivariate regression looks reasonable.
IMHO you need to train two models instead of one. The first one will predict angle, and the second one will predict distance.
Why you want to combine these two models? This is looks strange in the sense of the optimization metric. When you build angle model you minimize the error in radians. When you build distance model you minimize the error in meters. So what the metric you will minimize in single model case?
I believe next links will be useful for you:
https://www.mathworks.com/help/curvefit/surface-fitting.html
https://www.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html
Note: in some cases the data normalization (for example via zscore) greatly increases the fitting performance.
P.S. Try also ask at the https://stats.stackexchange.com/

What is the structure of an indirect (error-state) Kalman filter and how are the error equations derived?

I have been trying to implement a navigation system for a robot that uses an Inertial Measurement Unit (IMU) and camera observations of known landmarks in order to localise itself in its environment. I have chosen the indirect-feedback Kalman Filter (a.k.a. Error-State Kalman Filter, ESKF) to do this. I have also had some success with an Extended KF.
I have read many texts and the two I am using to implement the ESKF are "Quaternion kinematics for the error-state KF" and "A Kalman Filter-based Algorithm for IMU-Camera Calibration" (pay-walled paper, google-able).
I am using the first text because it better describes the structure of the ESKF, and the second because it includes details about the vision measurement model. In my question I will be using the terminology from the first text: 'nominal state', 'error state' and 'true state'; which refer to the IMU integrator, Kalman Filter, and the composition of the two (nominal minus errors).
The diagram below shows the structure of my ESKF implemented in Matlab/Simulink; in case you are not familiar with Simulink I will briefly explain the diagram. The green section is the Nominal State integrator, the blue section is the ESKF, and the red section is the sum of the nominal and error states. The 'RT' blocks are 'Rate Transitions' which can be ignored.
My first question: Is this structure correct?
My second question: How are the error-state equations for the measurement models derived?
In my case I have tried using the measurement model of the second text, but it did not work.
Kind Regards,
Your block diagram combines two indirect methods for bringing IMU data into a KF:
You have an external IMU integrator (in green, labelled "INS", sometimes called the mechanization, and described by you as the "nominal state", but I've also seen it called the "reference state"). This method freely integrates the IMU externally to the KF and is usually chosen so you can do this integration at a different (much higher) rate than the KF predict/update step (the indirect form). Historically I think this was popular because the KF is generally the computationally expensive part.
You have also fed your IMU into the KF block as u, which I am assuming is the "command" input to the KF. This is an alternative to the external integrator. In a direct KF you would treat your IMU data as measurements. In order to do that, the IMU would have to model (position, velocity, and) acceleration and (orientation and) angular velocity: Otherwise there is no possible H such that Hx can produce estimated IMU output terms). If you instead feed your IMU measurements in as a command, your predict step can simply act as an integrator, so you only have to model as far as velocity and orientation.
You should pick only one of those options. I think the second one is easier to understand, but it is closer to a direct Kalman filter, and requires you to predict/update for every IMU sample, rather than at the (I assume) slower camera framerate.
Regarding measurement equations for version (1), in any KF you can only predict things you can know from your state. The KF state in this case is a vector of error terms, and thus you can only predict things like "position error". As a result you need to pre-condition your measurements in z to be position errors. So make your measurement the difference between your "estimated true state" and your position from "noisy camera observations". This exact idea may be represented by the xHat input to the indirect KF. I don't know anything about the MATLAB/Simulink stuff going on there.
Regarding real-world considerations for the summing block (in red) I refer you to another answer about indirect Kalman filters.
Q1) Your SIMULINK model looks to be appropriate. Let me shed some light on quaternion mechanization based KF's which I've worked on for navigation applications.
Since Kalman Filter is an elegant mathematical technique which borrows from the science of stochastics and measurement, it can help you reduce the noise from the system without the need for elaborately modeling the noise.
All KF systems start with some preliminary understanding of the model that you want to make free of noise. The measurements are fed back to evolve the states better (the measurement equation Y = CX). In your case, the states that you are talking about are errors in quartenions which would be the 4 values, dq1, dq2, dq3, dq4.
KF working well in your application would accurately determine the attitude/orientation of the device by controlling the error around the quaternion. The quaternions are spatial orientation of any body, understood using a scalar and a vector, more specifically an angle and an axis.
The error equations that you are talking about are covariances which contribute to Kalman Gain. The covariances denote spread around the mean and they are useful in understanding how the central/ average behavior of the system is changing with time. Low covariances denote less deviation from the mean behavior for any system. As KF cycles run the covariances keep getting smaller.
The Kalman Gain is finally used to compensate for the error between the estimates of the measurements and the actual measurements that are coming in from the camera.
Again, this elegant technique first ensures that the error in the quaternion values converge around zero.
Q2) EKF is a great technique to use as long as you have a non-linear measurement construction technique. Be very careful in using EKF if their are too many transformations in your system, i.e don't try to reconstruct measurements using transformation on your states, this seriously affects the model sanctity and since noise covariances would not undergo similar transformations, there would be a chance of hitting singularity as soon as matrices are non-invertible.
You could look at constant gain KF schemes, which would save you from covariance propagation and save substantial computation effort and time. These techniques are quite new and look very promising. They actively absorb P(error covariance), Q(model noise covariance) and R(measurement noise covariance) and work well with EKF schemes.

May i know how to design the 3 phase converter for BLDC motor with Sinusoidal Commutation?

I have designed a BLDC motor model with Hall Sensors using simulink. It is working perfect with Trapezoidal commutation,with perfect trapezoidal back emf but when i go for sinusoidal commutation, the Hall sensors seem not to detect the electrical angle sequences. I want to know how to generate the three phase input voltages for driving the sinusoidally commutated bldc motor.Presently i am going with sensing the electrical angle using hall sensors and changing the hall state at every 60 degrees and switching the corresponding switches, but this somehow doesn't seem to work. I suppose i have to work on something like using a PWM signal or something. Please help me out.
BLDC motor applications have increased significantly in recent years as energy efficiency, durability, and maintenance-free operation have become increasingly valued. Motor control designers are using the performance characteristics inherent to BLDC motors, giving them a distinct advantage over common ac induction and brushed dc motors used in similar applications.
three phase power converter can be done as designers can simply choose the appropriate control algorithm and then concentrate on developing and evaluating their own target applications...

Rotational mechanical system in Simulink

I'm simulating a shaft system in Simulink, where I have to find the displacement of a mass. I'm not sure how to model this in Simulink because of the shaft and pulley. I'm looking through the documentation and the closest thing I see to a shaft is the wheel and axle block. But the shafts are connected by a flexible shaft, which is similar to a spring. Any ideas?
This is a fairly trivial task when using SimScape, which is especially made to simulate physical systems. You'll find most of the blocks you need ready from the library.
I've used SimScape to create a model of a complete hybrid truck... In Simulink it can be done, but you'll need to build your own differential equations for the task. In your case, the flexible axle could be translated to another block with a spring/damper system inside.
If you haven't got access to SimScape, you may also consider to use .m (matlab) files to write your differential equations. This can then be used as a block in Simulink, varying (only) a few parameters over time.
Take this step by step:
1. Draw a free body diagram, write out equations for all the forces as a function of displacement, velocity and acceleration of every element (including rotation obviously). For instance, you know that force on the box m will be *c*dy/dt* plus whatever the pulley experiences.
2. Sort out the rotation of the rod first. You know that *T=I*d(omega)/dt* if you get rid of the rest of the system. So, do something analogous to the car engine example of MatLab: Divide the input T by I to get the acceleration, integrate it to get velocity and one more time to get rotational displacement.
3. Keep adding bits one by one. First, you know that there will be a moment proportional to k*(theta_1-theta_2) acting. This will oppose the motion of rod 1 and act to create motion of rod 2. Add a new "branch" to your model to get theta_2 same way you got theta_1.
4. Go on including further elements...