|
|
— |
pl:prolog:pllib:model_circuit [2019/06/27 15:50] (aktualna) |
| ====== Model circuit ====== |
| {{tag>model}} |
| ===== Description ===== |
| A qualitative model of the circuit. |
| |
| **Source**: PROLOG programming for artificial intelligence, 3rd Edition, Harlow, 2001, ISBN 0-201-40375-7. |
| ===== Download ===== |
| Program source code: {{model_circuit.pl}} |
| ===== Listing ===== |
| <code prolog> |
| % Figure 20.11 A qualitative model of the circuit in Figure 20.10. |
| |
| :- op( 220, xfy, ..). |
| |
| % Qualitative model of electric circuit with resistor and capacitors |
| |
| landmarks( volt, [minf, zero, v0, inf]). % Voltage on capacitors |
| landmarks( voltR, [minf, zero, v0, inf]). % Voltage on resistor |
| landmarks( current, [minf, zero, inf]). |
| |
| correspond( voltR:zero, current:zero). |
| |
| legalstate( [ UC1, UC2, UR, CurrR]) :- |
| sum( UR, UC2, UC1), |
| mplus( UR, CurrR), % Ohm's law for resistor |
| deriv( UC2, CurrR), |
| sum( CurrR, current:CurrC1, current:zero/std), % CurrC1 = - CurrR |
| deriv( UC1, current:CurrC1). % CurrC1 = d/dt UC1 |
| |
| |
| initial( [ volt:v0/dec, volt:zero/inc, voltR:v0/dec, current:zero..inf/dec]). |
| </code> |
| ===== Comments ===== |
| |