Skip to content

Define Voltage, Current #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 7, 2022
Merged

Define Voltage, Current #51

merged 12 commits into from
Jun 7, 2022

Conversation

ven-k
Copy link
Member

@ven-k ven-k commented May 11, 2022

  • Define & export Voltage, Current signals in Electrical module
  • Adds tests to verify shape + signal way of defining analog sources

This finishes up the decoupling of Analog devices from shapes (from deprecated #18)

(While here, comments Short

ven-k added 3 commits May 11, 2022 19:36
- Adds tests to verify shape + dimension way of defining sources
@ven-k
Copy link
Member Author

ven-k commented May 16, 2022

@ChrisRackauckas can you approve the workflow runs?

@ven-k
Copy link
Member Author

ven-k commented May 16, 2022

@ChrisRackauckas can you approve the workflow runs one more time?

Also, now this PR is ready.

@codecov
Copy link

codecov bot commented May 16, 2022

Codecov Report

Merging #51 (5ba4ff6) into main (66d11d3) will decrease coverage by 3.25%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
- Coverage   71.77%   68.51%   -3.26%     
==========================================
  Files          23       23              
  Lines        1024      918     -106     
==========================================
- Hits          735      629     -106     
  Misses        289      289              
Impacted Files Coverage Δ
src/Electrical/Analog/sources.jl 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@ValentinKaisermayer
Copy link
Contributor

ValentinKaisermayer commented May 16, 2022

Can you please add the smooth signal definitions to Blocks and add Smooth versions of the sources? If possible via a flag or separate components.

_square_wave(t, δ, f, A, st) = A*2atan(sin(2π*(t-st)*f)/δ)/π
_step(t, δ, h, a) = h*(atan((t-a)/δ)/π + 0.5)
_triangular_wave(t, δ, f, A, st) = A*(1-2acos((1 - δ)sin(2π*(t-st)*f))/π)
_xH(t, δ, tₒ) = (t-tₒ)*(1+((t-tₒ)/sqrt((t-tₒ)^2+δ^2)))/2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't throw these away.

Copy link
Member Author

@ven-k ven-k May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to move them to Blocks. (But with a separate PR)

- Remove extra spaces in analog & thermal tests
- Add spaces in rotational tests
- Add broken test for ramp-voltage/current
@ven-k
Copy link
Member Author

ven-k commented May 18, 2022

I've updated the test according to SciMLStyleGuide

And 'have added the @test_broken Ramp+Voltage/Current which gives following output:

Ramp-Voltge-plot

@ven-k
Copy link
Member Author

ven-k commented May 29, 2022

Fixed Ramp test in test/analog.jl (along with saveat=0.01)

fixed-ramp

@ven-k
Copy link
Member Author

ven-k commented May 29, 2022

Now that #59 is complete, once that is merged, I'll add tests with Triangular and Square sources + Voltage/Current

end
end

# RL with different voltage sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already test Voltage, Current + all different sources in

  • "Current function generators"
  • "Voltage function generators"
  • RC with current sources
  • RC with voltage sources (I added this one to see if that improces code-cov; but that didn't seem to affect)

That's why I removed RL tests with all sources (simple RL is still around)

Do we want to keep this around?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's ok I think, as long as the RL test is there.


A source in which the current through its terminals is a square function of time.
Acts as current signal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a description about the convention of a positive current, i.e. which port has inflowing current if I is positive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, it is an ideal current source with no internal resistance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ValentinKaisermayer

Acts as an ideal current signal with no internal resistance modeled.
No further effects are modeled. Especially, the current flow will never end.
The inflowing current `I` is observed at the positive pin `p`

# States
- `i(t)`: [`A`]
  The output current

# Connectors
- `p`
 Positive pin
- `n`
  Negative pin
- `I`
  Input

Is this better?


Acts as voltage signal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific.
It is an ideal arbitrary waveform generator with no internal resistance, i.e. can source infinite currents.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an ideal arbitrary Voltage waveform generator with no internal resistance, i.e. can source infinite currents.

# States
- `v(t)`: [`V`]
  The voltage across this component

# Connectors
- `p`
  Positive pin
- `n`
  Negative pin
- `V`
  Input

@ValentinKaisermayer
Copy link
Contributor

This removes a bunch of components from Electrical/Analog/Sources and hence is breaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants