Skip to content
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

Addition of the Wattmeter and Ohmmeter Modules #682

Merged
merged 5 commits into from
Jul 9, 2017

Conversation

gildias
Copy link
Contributor

@gildias gildias commented Apr 20, 2017

Hello, my name is Alberto Silva and I'll be continuing the module development started by previous students from my institution (ISEP, Portugal).
This commit is related to the watt probe. Since this is my first interaction with github, I'd appreciate some information on whether I did the pull process correctly, and if not, what needs to be changed.
I'll likely be sending some more modules over the next weeks so I would like to know if I should keep developing over my existing files ( with the wattmeter in them ) or if I should start over for each module.
This is important since some modules will share modified files, with the obvious example of a makefile.
I have also added a simple pdf with 3 examples of the wattmeter working, hope it was attached correctly.
Thank you for your time.
Edit: I did not know you would receive the comment I made when i originally pushed to my git branch, thought this was the commit message, sorry about that.

Wattmeter examples.pdf

@andresmmera
Copy link
Contributor

I reckon that you pushed correctly :-)
I'm going to take a look to it. Good job

@andresmmera
Copy link
Contributor

Just a few comments, I promise I'll do some more revision later:

  • There are two typos at 'qucs-core/src/components/wprobe.cpp'. 'Potency Factor' is wrong, use 'Power Factor' instead

  • I think that it would be more convenient to use the following notation since it seems to be more common:

Parameter Meaning
Q Reactive power
P Real power
S Apparent power
PF Power factor

[1] https://en.wikipedia.org/wiki/Power_factor#Definition_and_calculation

@guitorri
Copy link
Member

Just to mention that this a cleanup of #546.

@guitorri
Copy link
Member

@gildias concerning your questions:

Yes your PR is fine. You can amend your commit message and push the branch once again. Something like:

cd ~/git/qucs/
git checkout wattmeter
git commit --amend # edit last commit message and save
git push -f [your origin] wattmeter

This will force update your fork/branch and this PR.

Indeed if you branch from develop for each new module the makefiles might create conflicts.

You could branch from the previous module for each new modules (wattmeter->moduleX then moduleX->moduleY ...) and we could merge things in this order just the last PR.

Perhaps is easier for you and for the review if you try to make one commit per module in this PR. So, I suggest you keep working on your wattmeter branch, one module per commit.

Please prepare a few example or test schematics for each module so we can add later to the test suite.

@andresmmera
Copy link
Contributor

Maybe I'm just nitpicking, but I think you can calculate the power factor as follows (PF = P/|S|):

setOperatingPoint ("FP", Wr/std::sqrt(WrWr+VAiVAi));

that way you can avoid the std::cos() and std::atan() functions

Notice that |S| = std::sqrt(Wr * Wr+VAi * VAi) = std::sqrt(P^2 + Q^2) and P = Wr (real power), Q = VAi (reactive power)

@gildias
Copy link
Contributor Author

gildias commented Apr 22, 2017

Thank you for all the precious information you provided.
Edited the commit according to your comments, now that I know how the process works, I'm sure it will go smoothly in the future.
If you have any additional concerns or advice regarding this commit, I'll be happy to address them.

I would appreciate some clarification on the subject of the test suite. I have the circuit schematics where the wattmeter was tested (as seen on the pdf file), and will add new examples as I progress through other modules, should i add these to the commit on a particular folder (qucs-test)?.

I would also like to know how I should approach adding a new commit to this pull request, If I follow the same process i did initially, am I given the option of creating a new commit instead of editing this one? Maybe that is the default behaviour and there is nothing to worry about, but I would welcome some confirmation.

Thank you for your time and consideration.

@gildias
Copy link
Contributor Author

gildias commented Apr 27, 2017

Pursuing the objective of helping students or beginners interested in electronics, I have now added the second commit, the Ohmmeter Module. It calculates the equivalent impedance in a given circuit.
If you have any advice or see anything that could be improved, I appreciate the information and will try to do so.
I would like to add the example schematics but I am still unsure on how I should approach that, so some clarification would be helpful.
Attached a pdf with working examples of the ohmmeter as well.
Thank you for your time and attention.
Ohmmeter examples.pdf

@gildias gildias changed the title Addition of the Wattmeter Module Addition of the Wattmeter and Ohmmeter Modules Apr 27, 2017
@gildias gildias force-pushed the wattmeter branch 2 times, most recently from d95c74f to efd54df Compare May 6, 2017 00:49
@gildias
Copy link
Contributor Author

gildias commented May 6, 2017

Resistance examples.pdf
Added the parameter of internal resistance to IProbe, Vprobe, Wprobe, Idc, Iac, Vdc and Vac.
The objective of this new function was to easily allow the study of the influence a real component can have on an electronic circuit.
As always, I will do my best to implement any feedback or recommended changes.
Regarding the question i sent to @guitorri email, I will update this commit depending on your answer, Andrés graciously helped with the other technical problems I was having.
Thank you for your time, and particularly to @andresmmera for his crucial help on the implementation of the voltmeter.

@andresmmera
Copy link
Contributor

You're welcome 😃
I've just tested (and reviewed the changes of) this last commit and they look good 👍

@gildias gildias force-pushed the wattmeter branch 2 times, most recently from ff8914e to 28edf66 Compare May 12, 2017 20:35
@gildias
Copy link
Contributor Author

gildias commented May 12, 2017

Added the phasorial and temporal digrams.
The phasorial diagram represents the data of a circuit on a complex plane. It can display more than one frequency at once, giving the option of easily analysing the effect of a different frequency on various parameters of the circuit, such as Power, Impedance, Current and Voltage. It is also helpful in determining whether a circuit is resistive, capacitive or inductive.
The temporal diagram acts like a basic oscilloscope, showing the evolution of a wave in relation to time, allowing for a simple analysis of the ofset between a number of waves.
The frequencies can be set on the diagrams themselves, as long as they have been simulated already, giving the option of simulating more than one frequency without running multiple simulations.
Both of these diagrams can be used exclusively on AC simulations.
If you have any comments, I will try to implement any helpful feedback.
Thank you for your time.
Diagrams examples.pdf

@gildias
Copy link
Contributor Author

gildias commented Jun 5, 2017

Hello, I probably won't be adding any other extensive commits to this pull request.
Therefore, i would appreciate it if an analysis could be made so that these new modules can be integrated into the official release. I think these additions would be extremely useful, especially for those interested in learning electronics. Your feedback would also be extremely helpful in regards to my project presentation.
I will do my best to answer any questions or comments that might occur, and will apply any changes that are deemed necessary.
Thank you for your time and consideration.

@gildias
Copy link
Contributor Author

gildias commented Jun 15, 2017

Hello, I apologise for insisting on this subject, but with the presentation date for my project getting closer, I would really appreciate some feedback from the QUCS team.
@andresmmera, as the person that helped me the most during development, could you possibly take a look at the PR as a whole and begin the testing process?
I completely understand if you're not available for any reason but I believe these modules will be a good addition to the QUCS comunity.
Thank you for your time and consideration.

@andresmmera
Copy link
Contributor

Hello @gildias,
I'll try to review the whole PR in (more or less) depth ASAP (I'll need maybe the weekend). In my opinion, this PR is a good one and for sure it'll add some value to the Qucs project.
Please notice that I'm not the guy making decisions about what PRs should be merged or not... It may take several months (or even years!) before someone merges a PR, so don't expect this PR is going to be merged soon.

@gildias
Copy link
Contributor Author

gildias commented Jun 15, 2017

I completely understand, if you have any questions or need any more files, such as test schematics to simplify the process for you, I'll make sure to help however I can. You can contact me through this thread or my email 1120196@isep.ipp.pt .
Thanks again.

@andresmmera
Copy link
Contributor

andresmmera commented Jun 17, 2017

Hello @gildias ,

I've been doing some checking stuff here and I've found the following:

  1. Temporal diagram
    1. The aspect ratio of the temporal diagram cannot be changed. Take for example a Cartesian plot, you can modify the default aspect ratio easily with the mouse. I think that temporal diagrams should behave like this too.
    2. Minor thing. I reckon that it would be more meaningful if you called it 'AC Temporal diagram'. Otherwise, it may mislead some user to think that this diagram could be used for other simulations.
    3. Qucs crashes when the the AC analysis is performed over a single freq. It seems that you have some problem with the length of a vector (I didn't have time to dig on that)
      It throws this message:

terminate called after throwing an instance of 'std::length_error'
what(): vector::_M_default_append
Aborted (core dumped)
See #691

  1. Phasor diagram

    1. It doesn't work when the AC analysis is performed over a single frequency.
    2. I've noticed you have to specify the freq using a QLineedit. This way the user can enter a frequency not present in the AC analysis. Did you consider using a QCombobox instead?
    3. The aspect ratio of the diagram cannot be changed too but I think that this is not so important here.
  2. Power probe component
    In the properties of the component you can specify the internal resistances of the voltage and current probes. I think that it would be clearer if you made explicit reference to that in the description field. The current properties look like this,

Name Value display Description
Riv 0 Ohm no Internal resistance, (0: disable), ideal behaviour
Rii 0 Ohm no Internal resistance, (0: disable), ideal behaviour

here we understand what Riv and Rii mean, but it may be not so clear for a random user. From my point of view, the description should explicitly describe what the parameter is. I mean, for example, the description of the 'Riv' parameter should be something like "Voltage probe internal resistor". I also think that is not necessary to clarify that 0 Ohm is the ideal behavior.

  1. Wattmeter component
    I've been checking again the wattmeter component and it is fine, but I noticed that the apparent power (S) is given as a complex number whereas it is usually S = abs(S). Take a look at the last example here

  2. Ohmmeter
    I think that the Ohmmeter performance can be checked using this schematic Here the input impedance of a filter is calculated using the Ohmmeter (AC analysis) and the S-parameter simulation. Both analyses give the same results, so it proves that the Ohmmeter works.

  3. Annoying warning (don't worry, it is not your fault)

The terminal output shows the following message:

'Warning: QLayout: Attempting to add QLayout "" to SaveDialog "", which already has a layout'

This stuff is related to this 2e9f7d1#commitcomment-21969888 A fix for that was made by @in3otd. Actually, this fix is already merged on the develop branch (deb4663), but your wattmeter branch seems to be behind develop. That is, your branch and develop have diverged since the day you've cloned your branch because people have merged stuff in develop and you've been working on your branch. So you have to bring these new changes from develop to your branch. In order to do this, you have to rebase your branch against develop:

git checkout wattmeter
git rebase develop

You may find a number of conflicts that cannot be solved automatically, so you'll have to solve them by hand... I usually do that using program called meld Once you fix a conflict, you have to mark it as resolved and do:

git rebase --continue

... and you have to repeat this step until you solved all conflitct. Then, you have to commit the changes and push as usual.

Apart from these issues, I consider the code is mergable and adds value to the AC simulation. Well done!

@guitorri
Copy link
Member

So, the people form ISEP want this code merged and hopefully released soon.
I don't have time these days to do review. @andresmmera you are in the best position to judge if the code is good to be merged. If so, tag it for the next milestone and merge.
You don't have to wait for one guy to decide and merge stuff into develop. The release branch is another story, and a bit of coordination might make sense.
It would be nice to have a few examples added to qucs-test later on.

@andresmmera
Copy link
Contributor

From my point of view, the code is worthwhile merging since it adds new capabilities to the AC analysis.
The issues I've posted here before are not a must, but, honestly the items 1.iii) and 2.i) should be solved before merging in order to guarantee proper functionality.

This was referenced Jul 3, 2017
gildias added 3 commits July 9, 2017 15:20
Wattmeter Module, modified the code as advised.
Changed the Power Triangle notations to their universal usage and the Power Factor calculation.
Thanks for all the precious information.
This probe should perhaps be called "Impedance Meter" instead, since
it measures the impedance, with its angular component and not only
the resistance, I kept it for simplicity and so it would fit on the
menus but maybe something to look into in the future.

The working loop is farly simple, it will act as a voltmeter on a first
instance, if it doesn't detect any other source it will then act as an
ohmmeter. By setting a current of 1A on its branch, and by following ohm's
law, it will then read the voltage differential between its two nodes
since if V=1*R,V=R, thus determining the impedance.

Hoping this doesn't update the previous commit and instead adds to the
already open Pull Request. Updated the Wprobe.png and its cpp in an
attempt to streamline it with the other components. Will add a simple
pdf with working examples of the ohmmeter on a comment.
Thanks for the attention.
Added the option of adding an internal resistance to both voltage sources,
ac and dc, which would equal a resistor in series with them.
The same applies to Iprobe. The default values for these components are 0 Ohms.
In the voltmeter, another series resistance is applied, but the default value is 1e12, I can change this if another value is prefered. The Wattmeter also has internal resistance, both for the voltage and the current part, the same principals were applied, as they were to their Probes.
Regarding the current sources, the internal resistor will result in a paralel with the component, and the default value was set to 1e12ohms as well.
I will add some working examples in a pdf.
Thanks to andresmmera for all his help and patience on this topic.
Edit:Fixed the default values of some components
Edit2:Added message, an Ri of 0 disables the parameter
gildias added 2 commits July 9, 2017 15:20
In this commit, I've added both the phasorial and temporal diagrams.
The phasorial diagram represents any complex value, and displays a line
which is oriented towards the angle, its size is determined by the real
component of that value.
It tracks the apparent power(S), Impedance(ohm), Current(I) and Voltage (V).
The temporal diagram resembles an oscilloscope, drawing a wave according
to its expected value across a certain time.
This means that it is now possible to analyse values that would otherwise need
a transient simulation to observe. It can track both current and voltage values.
Both of these diagrams, due to their functionalities, are limited to AC Simulations.
As always, I will attach a PDF on a comment with working examples, I'm keeping
my test schematics hoping they will be helpful in the future.
Waiting for information on how I should add them to the test suite.
Thank you for your time and attention.
The aspect ratio of the two new diagrams is now changeable.
Added some more clarity to the internal resistance parameter.
Deleted a lot of unused variables and functions.
Changed names of the diagrams and one variable to better follow convention.
Added components and diagrams to CMakelists.
Most of this was achieved under the guidance on Andrés Mera, I thank him for
all his help.
@andresmmera andresmmera merged commit 7492c26 into Qucs:develop Jul 9, 2017
@guitorri guitorri added this to the 0.0.20 milestone Jul 12, 2017
ra3xdh added a commit to ra3xdh/qucs that referenced this pull request Jul 13, 2017
andresmmera added a commit that referenced this pull request Jul 20, 2017
Fix CMake and various warnings after merging #682
gildias added a commit to gildias/qucs that referenced this pull request Aug 4, 2017
Most of their possible functions are displayed
@guitorri guitorri mentioned this pull request Oct 7, 2017
8 tasks
@andresmmera andresmmera mentioned this pull request Dec 7, 2017
andresmmera added a commit to andresmmera/qucs that referenced this pull request Dec 8, 2017
Because of the difficulty to mantain the Qucs code and merge PR from
older codebases, this PR removes all the features added in PR 682.

Hope this helps restructuring Qucs!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants