Circuit with a resistor and a coil - RL - 1D

General discussions about how to formulate a script for FlexPDE.

Circuit with a resistor and a coil - RL - 1D

Postby zygi151 on Thu Dec 03, 2020 9:49 pm

Hi all...

I try make, a simulation circuit with a resistor and a coil in !D area.

The assumptions are as follows:
-The behavior of the system after switching ON the voltage
-Show the operation of the circuit in a transient state
-transition to steady state
-The behavior of the system after switching OFF the voltage

Only the first point is well written (I think). During transition to steady state, flex reports an error.
I'm not sure the equations are well written. Comment in the code bellow.

I would be grateful for any suggestions.

Code: Select all
{
Uklad RL
}

TITLE "5_D1"

COORDINATES cartesian1

VARIABLES
    U,i, Ur, Ul

DEFINITIONS

Tstart = -1                  ! zero value
                   T0 = 0       ! Voltage is turn ON
                  T1 = 15   !
                        T2 = 200   ! Long time after - transition to steady state
                                    Tend = 250   ! Voltage is turn OFF   
                                        Tstep = 1

r = 3
L = 2

U1 = 10       U2 = 0

! ON and OFF Voltage - I`m not sure...   
Um =  if ( T < T0 ) then 0 else
                                    if ( T >= T0 and T < T2 ) then u1 else u2
                              

EQUATIONS
U : Um - Ur - Ul = 0    ! equation of Voltage

   ! Then:      
   !  Ur=I*r   ->  UL = L* di / dt   -> Um = I*r - L*di / dt    -> Um - I*r = L * di / dt   -> (Um - I*r) / L = di / dt   -> di = ((Um - i*r)/L )*t
   ! But I not sure...

i : i = ( t * ( Um - i * r ) / L )              ! di/dt ?

ur : Ur = U - L * dx( i  )  ! Resistor Voltage
ul : ul = U - i * r   ! Coil Voltage


BOUNDARIES
    REGION 1
       START ( Tstart )      
           LINE TO ( T0 )       
            LINE TO ( T1 )
            LINE TO ( T2 )   
              LINE TO  (  Tend  ) 

MONITORS
    TIME tstart TO  tend

PLOTS
    FOR T=Tstart BY Tstep to Tend     
   
      !history( uz, um) at (1)
        HISTORY( ur, ul )  AT ( 1 ) !window = 5

END
Last edited by zygi151 on Mon Mar 29, 2021 8:59 pm, edited 1 time in total.
zygi151
 
Posts: 7
Joined: Mon Aug 27, 2018 6:01 am

Re: Circuit with a resistor and a coil - !D

Postby moderator on Mon Dec 07, 2020 5:05 pm

There are a lot of things here that may contribute to the error you are experiencing (time step has fallen below halt threshold).

1) The most common are spatial or temporal discontinuities. You have at least two in your definition of Um. IF THEN statements are very dangerous for imparting discontinuities and should only be used if you can guarantee that the values the establish are continuous. When they are not, then you should use RAMP or SWAGE to ensure they are. In your case you could also use UPULSE (unit pulse), since your value switches from 0 to 10 and back to 0. UPULSE adds a small ramp in and out to ensure it is continuous.

2) I don't think you want separate equations to model separate voltages for each of the parts (coil and resistor). Voltage is one property throughout the system that will take on different values throughout the model. The equation you pose for voltage and the physical parameters of the device will decide what voltage is in each part of the model. If you were modelling the temperature, you wouldn't model separate equations for the temperature in each part of the device, would you? There is just one variable, temperature. Similarly with voltage. You should take a look at the examples in "Samples | Applications | Electricity" for ideas of how to model you system.

3) Similarly, you shouldn't need to model both I and V. Their relationship is simply a definition. Model one and use the definition to calculate the other. So you ultimately only need one equation for whatever variable you choose, and the rest are definitions and material parameters.

4) You likely will need some boundary conditions, too. Like voltage = 10 on one end and 0 on the other.

5) You used T0, T1, T2 for your BOUNDARIES section, but they appear to be used as times for turning on and off the voltage. I am not sure what that means. Are you stating the 1D problem domain as time? FlexPDE takes time into account when you have a PDE with time in it. The BOUNDARIES section is for the spatial definition of your model.
moderator
 
Posts: 875
Joined: Tue Jan 11, 2011 1:45 pm

Re: Circuit with a resistor and a coil - RL - 1D

Postby zygi151 on Mon Mar 29, 2021 9:28 pm

Well...
1) The most common are spatial or temporal discontinuities. ...

You have right. function UPULSE work fine.

2) I don't think you want separate equations to model separate voltages for each of the parts (coil and resistor).

Propobly you have a right...
the idea was to put it this way. In the end, I changed the entry a bit, but it's still not what I want.

3) Similarly, you shouldn't need to model both I and V. Their relationship is simply a definition. Model one and use the definition to calculate the other. So you ultimately only need one equation for whatever variable you choose, and the rest are definitions and material parameters.

I`t was a good tip. I try to do....

4) You likely will need some boundary conditions, too. Like voltage = 10 on one end and 0 on the other.

When I started working on it, I tried to do that too. I established the values for the transient, steady state. Eventually I gave up. Though I don't know if that's a good thing.

5) You used T0, T1, T2 for your BOUNDARIES section, but they appear to be used as times for turning on and off the voltage. I am not sure what that means...

Honestly, I don't know either :)
When I started working on the script, I decided to use the ELEVATION function, but found that the graph against time would be more accessible.

At this moment, I have something like that:
Code: Select all
[...]
Um = (upulse ( t- t1, t-t2) )
[...]
Uz : Uz = Um

i : dt( i ) = ( ( Uz - i*r ) / L ) * (t /tend)

U : Uz - ul - (i*r) = 0    ! -> Uz = Ul + Ur

Ul : Ul = U - (i*r)    ! I do not like it... but work
!Ul : Ul =   L * i  ! I want scribe Ul = L* di / dt, but i neet tip.
Attachments
rl-chyba ten.pde
(1.18 KB) Downloaded 8 times
zygi151
 
Posts: 7
Joined: Mon Aug 27, 2018 6:01 am


Return to FlexPDE Discussion

Who is online

Users browsing this forum: No registered users and 5 guests