Wednesday, March 6, 2019

Training a linear model to predict reference converter voltage

After the last post where I thought of mapping a function that links the grid current with the voltage across the filter capacitor:
vcf = f(ic)

Or, if I include the grid voltage as well:
vcf = f(ic, vgrid)

For now, let us try to create a linear model for this function f. And let us just use Python's in-built linear model function to achieve this. I will try to build some theory around it a little later if the results seem promising.

So, to create a linear model, the first step is to generate some training and testing data. For this I am running the simulation in open-loop. To begin with, let us consider a perfectly sinusoidal system without harmonics. So, the way I am doing this training is as follows.

The base case will be when we generate a modulation index which is such that the filter capacitor voltage will be approximately equal to the grid voltage.
m = vgrid/vdc

Where vdc is the dc bus voltage and that is needed to make sure the modulation index is between -1 and +1. From this state of equilibrium, I will add a random sinusoid. So, I created a random array:

This will have random floats between 0 and 0.1. I add to the modulation index:
m = vgrid/vdc + random[i]*math.sin(phase_angle)

The counter i will be initialized to 0 but every 0.1s, will be incremented to fetch the next random number. This is applied to PWM. The result is a waveform like this in which I have plotted - the grid voltage, the voltage across the filter capacitor and current injected into the grid. Every 0.1s, the current changes quite often drastically as the modulation signal has changed with the new random value.

A zoom between two changing values:

I am going to let this simulation run to it's limit of 1s. After that will extract the data into a Pandas data frame. And apply machine learning algorithms.

There is a very possibility that I am doing may not be current. We may need help in the control. But I feel this is a great way to learn about a system.

No comments:

Post a Comment