SpiceSharp / SpiceSharpBehavioral

This library extends Spice# components with behavioral sources for modelling electronics circuits.
MIT License
6 stars 5 forks source link

SafePow is not used in SimpleParserHelper #12

Closed marcin-golebiowski closed 4 years ago

marcin-golebiowski commented 4 years ago

I will publish PR later today.

svenboulanger commented 4 years ago

I believe the issue is: do we want SafePow() in SimpleParser? It can't be used as a parser for components because it's not capable of calculating derivatives. The usecase for SimpleParser is completely different.

marcin-golebiowski commented 4 years ago

The reason I want it is that simulation for the netlist posted in #4 doesn't finish with the result but with "NaN"

marcin-golebiowski commented 4 years ago

With that change I have correct results I believe.

svenboulanger commented 4 years ago

The example you linked to seems to use ExpressionTreeDerivativeParser. The other parser that would require SafePow() is SimpleDerivativeParser. I may be wrong, but I believe I implemented a "safe" pow() method for both of them.

marcin-golebiowski commented 4 years ago

In SpiceSharpParser I also use SimpleParser for initial values.

svenboulanger commented 4 years ago

Could you elaborate on that? How do you deal with custom variables, parameters, functions, etc.? What do you use the initial values for?

marcin-golebiowski commented 4 years ago

No problem but in the evening.

/Marcin

marcin-golebiowski commented 4 years ago

I use SimpleParser for:

1) Getting list of variables from expressions. For example: R1 0 1 {a+b+c} . I need then to update value of property (besides behavioral components, there is second mechanism for property updates for other components)

2) Evaluating .IF clauses. For example: .IF (a == 0) .ENDIF

3) Evaluating values of custom functions.

marcin-golebiowski commented 4 years ago

@svenboulanger I've changed the SpiceSharpParser to use only one type of parser: SimpleDerivativeParser