[PYTHON] Boost current simulation

duty is a sequential calculation


# coding: utf-8

# In[278]:


get_ipython().magic('matplotlib inline')
import matplotlib.pyplot as plt


# In[279]:


import numpy as np
import math


# In[280]:


points = 360
ac_freq = 50 #Hz
ac_t = 1/ac_freq / 2 #Half wave: →/2
ac_volt_real = 220 #V
ac_volt_max = ac_volt_real * math.pow(2,0.5)
reactor_H = 40 #mH
dc_volt = 320
target_dc_volt = 320
career = 40 * math.pow(10,-6)
t_delt = ac_t / points
ep_dead_time_count = 3
dead_time = career * ep_dead_time_count


# In[281]:


def calc_time(i_point):
    return ac_t / points * i_point 

def calc_acv_sin(i_time):
    rad = (i_time / ac_t) * math.pi * 1 #Half wave:*2→*1
    acv_sin = ac_volt_max * math.sin(rad)
    return acv_sin

def calc_duty(t, target_dc_volt, dc_volt, acv, aca_sum):
    duty = 0.4
    return duty


# In[282]:


#10ms, 40us, duty:100%, 0.01%Notched
print("resolution:",10*1000 / 40 * (100/0.1))


# In[283]:


#With 250,000 points
#Create an ACV sine wave
#40 for every 40us%ON60%OFF, 30%ON70%OFF, ....,Somehow with points
#Or rather, it is impossible with map because it is a duty calculation from sequential current ...


# In[284]:


points_list = list(range(0,points))
time_list = list(map(calc_time, points_list))
acv_sin_list = list(map(calc_acv_sin, time_list))


# In[285]:


plt.plot(time_list, acv_sin_list)


# In[286]:


career_count = 0
aca_sum = 0.0
duty = 0
duty_on_count = 0
duty_off_count = 0
duty_on_time = 0
duty_off_time = 0
for t in time_list:
    ac_volt = calc_acv_sin(t)
    if t < dead_time: #Duty is 0, but ACV and ACA are likely to be calculated, so if nesting or change is necessary
        duty = 0
    if t >= 0.001 and ac_volt < 30: #1ms,Duty is 0, but ACV and ACA are likely to be calculated, so if nesting or change is necessary
        duty = 0
        
    if t >= (career * career_count): #Career every 40us_Feeling to update count and duty. I brought this up to calculate the duty for the first time
        career_count += 1
        duty = calc_duty(t, target_dc_volt, dc_volt, ac_volt, aca_sum)
        duty_on_count = 0
        duty_off_count = 0
    else:
        if t < ((career * (career_count-1)) + (duty * career)): #If duty is being output
            duty_off_time = t_delt * duty_off_count
            duty_on_count += 1
        else:
            duty_on_time = t_delt * duty_on_count
            duty_off_count += 1
    
        


# In[ ]:





Recommended Posts

Boost current simulation
Escalator simulation