The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Modeling >> Behavioral Models >> "Charge" and  "Flux" natures - theirs usefuln
https://designers-guide.org/forum/YaBB.pl?num=1163163662

Message started by Pavel on Nov 10th, 2006, 5:01am

Title: "Charge" and  "Flux" natures - theirs usefuln
Post by Pavel on Nov 10th, 2006, 5:01am

Hello

1. I don't understand how one can exploit Charge and Flux natures in disciplines.vams.
I tried to find examples on Internet targeting access functions 'Q' and 'Phi', but I failed.
There are examples where people emulate charges, but charges are declared as real variables .
Taking derivatives from these 'real variable' charges they calculate current. So what is usefulness of Charge and Flux natures declared in disciplines.vams.

In my case I want to simulate reception of magnetic flow on RFID tag. How to proceed - just apply signal on tag borns and ignore existance of inductor? Or there is more "smart" approach?

2. Trying to simulate underlying code I have fatal initialization error.

module L_FLUX_test;
electrical A, B, gnd;
ground gnd;
parameter real FREQ = 100;
parameter real AMPL = 10;
real flux;

inductor #(.l(50u)) L1 (A,B);
resistor #(.r(1k)) R1 (A, gnd);
resistor #(.r(1k)) R2 (B, gnd);

analog begin
     @ (initial_step) flux = 0;
     flux = AMPL*sin(`M_TWO_PI*FREQ*$abstime);
     V(A, B) <+ ddt(flux);
     $bound_step(0.05/FREQ);
end

endmodule


Fatal error found by spectre during topology check.
   The following branches form a loop of rigid branches (shorts) when added to
       the circuit:
       L_FLUX_test:A_B_flow (from L_FLUX_test.A to L_FLUX_test.B)

spectre terminated prematurely due to fatal error.
ncsim: *E,RNAERR: Simulation is complete, analog initialization error.

Regards

Pavel.

Title: Re: "Charge" and  "Flux" natures - theirs use
Post by Geoffrey_Coram on Nov 10th, 2006, 5:30am

Pavel -
You have two things across (A,B) that are both trying to set the voltage:

inductor #(.l(50u)) L1 (A,B);

and

V(A, B) <+ ddt(flux);

At time=0, both are shorts (V=0), and you can't put two 0-volt voltage sources in parallel (physically, any arbitrary current can flow in the loop created by the two of them; mathematically, you have a singular matrix).

I generally work with the electrical discipline, that is, with voltage and current, rather than with flux and charge.  I suppose you could define a flux source and a module that had a flux input and converted it to a voltage.


Code:
module flux_source(out);
 inout out;
 magnetic out;
 parameter real FREQ = 100;
 parameter real AMPL = 10;

 analog begin
   Phi(out) <+ AMPL*sin(`M_TWO_PI*FREQ*$abstime);
   $bound_step(0.05/FREQ);
 end
endmodule

module flux_recv(in, vout);
 inout in, vout;
 magnetic in;
 electrical vout;

 analog
   V(vout) <+ ddt(Phi(in));
endmodule

Title: Re: "Charge" and  "Flux" natures - theirs usefuln
Post by Pavel on Nov 10th, 2006, 6:50am

Thank you Geoffrey,

Your response confirms my original opinion concerning Charge and Flux natures.
They are USELESS.
Supposing that one knows Charge (or Flux) functions: CHARGE = F1(time), FLUX = F2(time).
Current through capaitor and voltage on inductor could be assigned ignoring physical nature of charge (flux).
One can declare CHARGE and FLUX as real variables - it will be sufficient. Then apply to them ddt function and we have current and voltage...

electrical A,B,C,D;
real CHARGE, FLUX;
analog begin
  CHARGE = sin(`M_TWO_PI*FREQ*$abstime);
  FLUX = sin(`M_TWO_PI*FREQ*$abstime);
  I(A, B) <+ ddt(CHARGE);
  V(C,D) <+ ddt(FLUX);
end

Or I miss something ...

Concerning your verilog-A code - the inductor isn't mentionned.
How can I modelize the reception of a RF-signal by LC-tank.

Regards.

Pavel.

Title: Re: "Charge" and  "Flux" natures - theirs use
Post by Geoffrey_Coram on Nov 13th, 2006, 3:12am


Pavel wrote on Nov 10th, 2006, 6:50am:
Your response confirms my original opinion concerning Charge and Flux natures.
They are USELESS.
Supposing that one knows Charge (or Flux) functions: CHARGE = F1(time), FLUX = F2(time).
Current through capaitor and voltage on inductor could be assigned ignoring physical nature of charge (flux).
One can declare CHARGE and FLUX as real variables - it will be sufficient. Then apply to them ddt function and we have current and voltage...

Or I miss something ...


You did miss something.  The creation of different natures allows you to set different tolerances on the variables: if the simulator applied ABSTOL (which usually runs around 1e-12 in Spice-like simulators) to charge variables (which in modern MOSFETs runs in the 1e-18 range, then you could never expect the charge to give accurate results, because any answer would be below the tolerance.

Also, there's some mention about compatible disciplines -- a good simulator will warn you (or give an error) if you accidentally connect a magnetic port to one that is really supposed to be electrical.  I heard a story once about a designer who accidentally connected the "thermal terminal" of a bipolar model with self-heating to an electrical wire in a Spice simulator; he thought Kirchoff's current law was being violated because current was disappearing into the "thermal ground" of the BJT model (and he must have been getting the wrong answer because his BJT was incorrectly computing its temperature).


Quote:
Concerning your verilog-A code - the inductor isn't mentionned.
How can I modelize the reception of a RF-signal by LC-tank.


I think you'd need to write your own inductor with the usual two electrical ports and a magnetic port to bring in the RF:


Code:
module fluc_recv(a,b,rf_in);
 inout a, b, rf_in;
 electrical a, b;
 magnetic rf_in;
 parameter real L = 1n from (0:inf);

 analog
   V(a,b) <+ ddt(L * I(a,b) + Phi(rf_in));

endmodule

Title: Re: "Charge" and  "Flux" natures - theirs usefuln
Post by Pavel on Nov 15th, 2006, 12:07am

Thanks Geoffrey

I tested your suggestion. Indeed RF field declared as real doesn't work.

module L_FLUX_test;
electrical A, B, C, D, emf, emf_real, gnd;
magnetic flux;
ground gnd;
parameter real FREQ_RES = 13.56M;
parameter real FREQ = FREQ_RES*2;
parameter real AMPL = 1u;
parameter real Cc = 10p;
parameter real Lc = 1/pow(`M_TWO_PI*FREQ_RES,2)/Cc;
parameter real Rlkg = 1G;
real flux_real;

resistor #(.r(1k)) R1 (A, gnd);
resistor #(.r(1k)) R2 (B, gnd);

resistor #(.r(1k)) R3 (C, gnd);
resistor #(.r(1k)) R4 (D, gnd);

analog begin

     Phi(flux) <+ AMPL*sin(`M_TWO_PI*FREQ*$abstime);            
     V(emf) <+ -ddt(Phi(flux));      
     I(A,B) <+ V(A,B)/Rlkg + Cc*ddt(V(A,B)) + 1/Lc*idt(V(A,B)+V(emf));
     
     flux_real = AMPL*sin(`M_TWO_PI*FREQ*$abstime);            
     V(emf_real) <+ -ddt(flux_real);      
     I(C,D) <+ V(C,D)/Rlkg + Cc*ddt(V(C,D)) + 1/Lc*idt(V(C,D)+V(emf_real));
     
     $bound_step(0.05/FREQ);
end

endmodule


You could see the simulation results in attachment picture.

Best Regards

Pavel.

Title: Re: "Charge" and  "Flux" natures - theirs use
Post by Geoffrey_Coram on Nov 16th, 2006, 11:33am


Quote:
I(A,B) <+ V(A,B)/Rlkg + Cc*ddt(V(A,B)) + 1/Lc*idt(V(A,B)+V(emf));


The LRM says that idt() without an initial condition has to be used in a feedback loop that forces its inputs to zero.  I would suggest you look into that, or convert to ddt() as I used in my module.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.