How to change the circuit for a pulse-echo response simulation

When building a pulse-echo model in OnScale, it is necessary to have a different circuit when we send the pulse and then we receive it back.

In OnScale Analyst Mode, it is possible to switch the circuit after a certain number of simulation loops.

circuit_change_pulse_echo_onscale.png

As long as the two circuits have the same amount of components in them, then they can be swapped reliably.

The general algorithm to do that is:

  1. Connect circuit 1
  2. Run model for a period of time, usually until the charge has settled
  3. Use the piez conn command to change the circuit
  4. Continue the run until complete

Example Code

First we need to define the 2 circuits like in the code portion below:

 
symb r1 = 100e3
symb r2 = 50 if noexist
symb r3 = 10e3
symb r4 = 100e3 if noexist
symb r5 = 1e3

symb c1 = 10e-9

circ
	defn trns
	elem cpac shnt $c1
	elem rest shnt $r5

	elem rest shnt $r3
	elem rest sers $r2	
circ
	defn recp
	elem cpac shnt $c1
	elem rest shnt $r5

	elem rest shnt $r3
	elem rest sers $r1	

The first "trns" circuit is then connect to the top electrode load using the "conn" (connect) command

 
piez
	wndo $i1 $i2 $j2 $j3 /*selection of the piezoelectric zone for the solver

	defn top /* selection of the top electrode
	node $i1 $i2 $j3 $j3

	defn bot /* selection of the bottom electrode
	node $i1 $i2 $j2 $j2

	conn top trns volt func /* connection of the trns circuit to top electrode
	bc bot grnd /* definition of ground bottom electrode as a bc
	end

In the simulation execution bloc, we first execute 10 loops (proc plot 10 command), then we switch the circuit to "recp" using the piez conn command

finally, we execute the rest of the simulation with proc plot $nloops

 
symb #get { step } timestep	
symb simtime = 50.e-6	
symb nexec = nint ( $simtime / $step )
symb nloops = 50

symb nruns = $nexec / $nloops

proc plot save
exec $nruns
grph
	nvew 2 1
	colr tabl data 6
	plot pres
	plot 2
	end
end$ proc

proc plot 10 /* We execute first 10 loops
term

piez      /*  change resistor value for receive mode....
     conn top recp volt func   /* connect in receiving circuit 
     end


proc plot $nloops /* We execute the remaining $nloops in the simulation
term