

Electr, a language for electronic formulas - lkdjiin
https://github.com/lkdjiin/electr

======
bariumbitmap
Interesting idea, particularly the prompting for uknown quantities, but GNU
units already does a pretty good job of this.

[https://en.wikipedia.org/wiki/GNU_Units](https://en.wikipedia.org/wiki/GNU_Units)

Calculations aren't quite as short as "1mA 3K", but pretty close to it.

    
    
        You have: 1mA 3kohm
        You want: V
                * 3
                / 0.33333333
    

It has long and short SI prefixes, scientific notation, implicit
multiplication, and a history dating back to Unix itself.

By the way, one of the example calculations (calculation of 205 Hz) is too
high by a factor 10.

    
    
        You have: 1 / (2 pi 0.5microF sqrt(11kohm 22kohm))
        You want: Hz
                * 20.461734
                / 0.048871712

~~~
lkdjiin
Thanks, I should check GNU Units… (and the calculation is now fixed on Github)

------
0h139
As a student, I've found the TI-Nspire CAS software to work pretty well with
units, but of course it's not free.

[https://education.ti.com/en/us/products/computer_software/ti...](https://education.ti.com/en/us/products/computer_software/ti-
nspire-software/ti-nspire-student-software/tabs/overview)

~~~
gbl08ma
Sorry for the accidental downvote, I actually wanted to upvote :(

------
nyir
That has probably a lot of overlap with Frink
[https://futureboy.us/frinkdocs/](https://futureboy.us/frinkdocs/), though
after a quick try the output could be nicer, e.g. like described in this
document.

~~~
lkdjiin
Thanks for pointing this one. I don't think java is the right tool for what I
have in mind (because of the JVM overhead) but I'll definitely try Frink.

~~~
scotty79
We could reimplement it in js to freely mix and match with other js based
languages.

------
compumike
Not command line (or open source), but we've built most of this capability and
more into CircuitLab
[https://www.circuitlab.com/](https://www.circuitlab.com/) (disclosure: I'm
one of the developers) -- we have to manage units, metric prefixes, all sorts
of arbitrary expressions
[https://www.circuitlab.com/docs/expressions/](https://www.circuitlab.com/docs/expressions/)
, real and frequency domain, etc. We also have schematic-wide parameters, the
ability to define functions of those parameters to set component values,
and/or to set real-time arbitrary behavioral voltages and currents within the
circuit graph, etc. On top of that, iteratively solved non-linear feedback
systems, Laplace-domain filter notation.... It gets complicated fast!

One of the cool things about understanding circuits and simulation is that you
can use the same concepts and tools to model non-electronics-domain problems:
thermal systems, mechanical systems, etc. You can combine these, too: for a
simple non-confidential example, we recently did modeling of the fusing of tin
whiskers, which involves solving the electrical and thermodynamic properties
at the same time.

~~~
yigitdemirag
(not-related) I'm happy that you show my twitter post on your homepage. I do
love using circuitlab.

~~~
compumike
Awesome -- thanks so much for that! It always makes it a happy day in the
office when we hear from happy users :)

------
csn
Why can't Electr detect unit K form "10K + 200"? It's the only unit present in
the equation.

Why kilo-ohms are denoted with "K" while milliamperes are using the proper SI
unit "mA"? Why not to use "Ω" and "kΩ"? We have that symbol in high ASCII.

Probably just my ignorance of programming language design speaking but I
really have to ask.

~~~
mallin
In practical engineering (on circuit diagrams, bills of materials, etc), you
almost never see the "Ω" symbol. "K" is used for kΩ, "M" for MΩ, and "R" for Ω
(as in 330R is a 330Ω resistor).

It's nothing to do with programming language design.

------
leni536
Nice idea. Unit handling can be hard though, there are several problems that
you can bump into:

\- It's not always evident what unit you want show after a calculation. (As/Vm
or C/Vm, kV/m or V/mm)

\- You should handle fractional power of units (like V/sqrt(Hz))

I recently discovered orpie and that one has unit handling. It has electrical
(and all sort of physical) units and handles both of this problems fairly
well. For the calculation result's unit it uses the one that comes evidently
from the source terms (1kV* 0.5mA=0.5kV* mA), then the user can convert it to
other equivalent units or to SI base units. It's an RPN calculator so one has
to get the hang of it.

Edit:

Oh, electric engineers like to think of "rad" as a unit (like in rad/s and
Hz). I think it's impossible to handle it well.

~~~
lkdjiin
Thanks for the advices ;)

------
galkk
Very strange that nobody mentioned relative mainstream language that has the
same feature: F#

[http://fsharpforfunandprofit.com/posts/units-of-
measure/](http://fsharpforfunandprofit.com/posts/units-of-measure/)

------
scotty79
I wonder why Frink isn't more popular:

[https://futureboy.us/frinkdocs/](https://futureboy.us/frinkdocs/)

... and why in general programmers like to think about bare numbers and love
to differentiate them into floats and ints of various length (like it's the
90-ies) but don't care if they are volts or meters.

