# What's wrong with my code that it's figure is not matched with simulation

**URL:** <https://discourse.julialang.org/t/whats-wrong-with-my-code-that-its-figure-is-not-matched-with-simulation/62104>\
**Category:** Modelling & Simulations\
**Tags:** package\
**Created:** [May 30, 2021, 9:48pm UTC](https://discourse.julialang.org/t/whats-wrong-with-my-code-that-its-figure-is-not-matched-with-simulation/62104 "2021-05-30T21:48:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajad\_ghassemi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sajad_ghassemi/32/25241_2.png) [@sajad\_ghassemi](https://discourse.julialang.org/u/sajad_ghassemi)\
**Post date:** [May 30, 2021, 9:48pm UTC](https://discourse.julialang.org/t/whats-wrong-with-my-code-that-its-figure-is-not-matched-with-simulation/62104/1 "2021-05-30T21:48:42Z")

</div>

Dear friends. I am a newbie and I asked many questions to simulate a full-bridge rectifier through ACME.jl and the circuit is as follows:  
 ![fig1](https://global.discourse-cdn.com/julialang/original/3X/6/b/6b86743f0ef66a8d06993e2487fa1878058462de.png)  
and the current is as follows

 ![error](https://global.discourse-cdn.com/julialang/original/3X/1/f/1f79690c3703e8de6033342e6f2b0055088e6a09.png)  
my code using ACME.jl package in julia as follows :  
using ACME  
using Plots  
plotly()  
Plots.PlotlyBackend()

circ = @circuit begin  
j\_in = voltagesource()  
l1 = inductor(1e-3)  
d1 = diode(;is=1e-12, η = 1)  
d2 = diode(;is=1e-12, η = 1)  
d3 = diode(;is=1e-12, η = 1)  
d4 = diode(;is=1e-12, η = 1)  
c1 = capacitor(1e-3)  
r1 = resistor(20)  
i\_out = currentprobe()  
j\_in[+] ⟷ l1[1]  
j\_in[-] ⟷ gnd  
l1[2] ⟷ d1[+] ⟷ d4[-]  
gnd ⟷ d2[+] ⟷ d3[-]  
d1[-] ⟷ i\_out[+]  
i\_out[-] ⟷ d2[-] ⟷ r1[1] ⟷ c1[1]  
d4[+] ⟷ d3[+] ⟷ r1[2] ⟷ c1[2]  
end

fs = 44100;  
fsig = 1000;  
dt = 1/fs  
t = 0:dt:1  
model = DiscreteModel(circ, 1/fs)  
y = run!(model, 310_sin.(2_π_fsig ._ t’))

plot(t, y’)  
and the amplitude of current as follows is not 70 and it is only 22 A  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/7/a76716a3d897c4d6e1feefd9cddb6cc85aaa20e3.png)

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [May 31, 2021, 7:51am UTC](https://discourse.julialang.org/t/whats-wrong-with-my-code-that-its-figure-is-not-matched-with-simulation/62104/2 "2021-05-31T07:51:15Z")

</div>

Use triple backtick fences to format your code.

How did you get the first graph/why are you expecting 70?

---

<div class="post-metadata">

**Author:** ![sajad\_ghassemi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sajad_ghassemi/32/25241_2.png) [@sajad\_ghassemi](https://discourse.julialang.org/u/sajad_ghassemi)\
**Post date:** [May 31, 2021, 9:33am UTC](https://discourse.julialang.org/t/whats-wrong-with-my-code-that-its-figure-is-not-matched-with-simulation/62104/3 "2021-05-31T09:33:34Z")

</div>

Dear friend,

Thanks for the answer and suggesteion to format my code. I didn’t know that

I got the first graph from simulation in EMTP-RV which is an electrical engineering software for transient study and I am sure the amplitude shuld be 70 ampere.  
RLC paramters in code are matched with simulation but diode is different.  
I also changed the diode paramteres but it doesn’t impact current amplitude
