Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
cassiopee
jalhyd
Commits
405eefc8
Commit
405eefc8
authored
Nov 15, 2019
by
Mathias Chouet
🍝
Browse files
SPP: better log management, powers may now be non-integers
parent
9c839a9a
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/spp.ts
View file @
405eefc8
...
...
@@ -68,7 +68,13 @@ export class SPP extends Nub {
vPartielle
=
0
;
for
(
const
c
of
this
.
_children
)
{
if
(
c
.
uid
!==
sVarCalc
.
uid
)
{
vPartielle
+=
c
.
Equation
(
"
Y
"
).
vCalc
;
const
cRes
=
c
.
Calc
(
"
Y
"
);
if
(
cRes
.
ok
)
{
vPartielle
+=
cRes
.
vCalc
;
}
else
{
this
.
result
.
log
.
add
(
new
Message
(
MessageCode
.
ERROR_SOMETHING_FAILED
));
return
this
.
result
;
}
}
}
vPartielle
=
this
.
prms
.
Y
.
v
-
vPartielle
;
...
...
@@ -76,13 +82,20 @@ export class SPP extends Nub {
vPartielle
=
1
;
for
(
const
c
of
this
.
_children
)
{
if
(
c
.
uid
!==
sVarCalc
.
uid
)
{
vPartielle
*=
c
.
Equation
(
"
Y
"
).
vCalc
;
const
cRes
=
c
.
Calc
(
"
Y
"
);
if
(
cRes
.
ok
)
{
vPartielle
*=
cRes
.
vCalc
;
}
else
{
this
.
result
.
globalLog
.
add
(
new
Message
(
MessageCode
.
ERROR_SOMETHING_FAILED
));
return
this
.
result
;
}
}
}
if
(
vPartielle
===
0
)
{
const
m
=
new
Message
(
MessageCode
.
ERROR_DIVISION_BY_ZERO
);
m
.
extraVar
.
symbol
=
"
vPartielle
"
;
return
new
Result
(
m
);
this
.
result
.
resultElement
.
addMessage
(
m
);
return
this
.
result
;
}
vPartielle
=
this
.
prms
.
Y
.
v
/
vPartielle
;
}
...
...
@@ -110,12 +123,22 @@ export class SPP extends Nub {
if
(
this
.
operation
===
SPPOperation
.
SUM
)
{
v
=
0
;
for
(
const
c
of
this
.
_children
)
{
v
+=
c
.
Equation
(
"
Y
"
).
vCalc
;
const
cRes
=
c
.
Calc
(
"
Y
"
);
if
(
cRes
.
ok
)
{
v
+=
cRes
.
vCalc
;
}
else
{
return
new
Result
(
new
Message
(
MessageCode
.
ERROR_SOMETHING_FAILED
));
}
}
}
else
if
(
this
.
operation
===
SPPOperation
.
PRODUCT
)
{
v
=
1
;
for
(
const
c
of
this
.
_children
)
{
v
*=
c
.
Equation
(
"
Y
"
).
vCalc
;
const
cRes
=
c
.
Calc
(
"
Y
"
);
if
(
cRes
.
ok
)
{
v
*=
cRes
.
vCalc
;
}
else
{
return
new
Result
(
new
Message
(
MessageCode
.
ERROR_SOMETHING_FAILED
));
}
}
}
break
;
...
...
src/structure/parallel_structure.ts
View file @
405eefc8
...
...
@@ -73,7 +73,7 @@ export class ParallelStructure extends Nub {
/**
* Calcul de la somme des débits de chaque structure
* @param iExcept Index de la structure à ne pas additionner (optionel)
* @param iExcept Index de la structure à ne pas additionner (option
n
el)
*/
public
CalcQ
(
iExcept
?:
number
):
Result
{
if
(
iExcept
!==
undefined
)
{
...
...
src/util/message.ts
View file @
405eefc8
...
...
@@ -4,6 +4,9 @@ export enum MessageCode {
*/
ERROR_OK
,
/** generic error stating that somthing triggered a fatal error leading to an undefined vCalc */
ERROR_SOMETHING_FAILED
,
/** abstract showing number of error messages encountered in an iterative calculation */
WARNING_ERRORS_ABSTRACT
,
...
...
@@ -302,6 +305,9 @@ export enum MessageCode {
*/
ERROR_STRUCTURE_Z_EGAUX_Q_NON_NUL
,
/** On essaye d'appliquer une puissance non entière à un nombre négatif */
ERROR_NON_INTEGER_POWER_ON_NEGATIVE_NUMBER
,
/** abstract showing number of warning messages encountered in an iterative calculation */
WARNING_WARNINGS_ABSTRACT
,
...
...
src/yaxn.ts
View file @
405eefc8
...
...
@@ -27,24 +27,15 @@ export class YAXN extends ChildNub {
switch
(
sVarCalc
)
{
case
"
Y
"
:
v
=
this
.
prms
.
A
.
v
*
Math
.
pow
(
this
.
prms
.
X
.
v
,
this
.
prms
.
N
.
v
);
break
;
/* case "X":
// X = (Y/A)^(1/N)
if (this.prms.A.v === 0) {
const m = new Message(MessageCode.ERROR_DIVISION_BY_ZERO);
m.extraVar.symbol = "A";
return new Result(m);
}
if (this.prms.N.v === 0) {
const m = new Message(MessageCode.ERROR_DIVISION_BY_ZERO);
m.extraVar.symbol = "N";
if
(
this
.
prms
.
X
.
v
<
0
&&
!
Number
.
isInteger
(
this
.
prms
.
N
.
v
))
{
const
m
=
new
Message
(
MessageCode
.
ERROR_NON_INTEGER_POWER_ON_NEGATIVE_NUMBER
);
m
.
extraVar
.
X
=
this
.
prms
.
X
.
v
;
m
.
extraVar
.
N
=
this
.
prms
.
N
.
v
;
return
new
Result
(
m
);
}
v =
Math.pow((
this.prms.
Y
.v
/
this.prms.
A
.v
), (1 /
this.prms.N.v)
)
;
v
=
this
.
prms
.
A
.
v
*
Math
.
pow
(
this
.
prms
.
X
.
v
,
this
.
prms
.
N
.
v
);
break
;
*/
default
:
throw
new
Error
(
"
YAXN.Equation() : invalid variable name
"
+
sVarCalc
);
}
...
...
src/yaxn_params.ts
View file @
405eefc8
...
...
@@ -23,7 +23,7 @@ export class YAXNParams extends ParamsEquation {
super
();
this
.
_A
=
new
ParamDefinition
(
this
,
"
A
"
,
ParamDomainValue
.
ANY
,
undefined
,
rA
,
ParamFamily
.
ANY
);
this
.
_X
=
new
ParamDefinition
(
this
,
"
X
"
,
ParamDomainValue
.
ANY
,
undefined
,
rX
,
ParamFamily
.
ANY
);
this
.
_N
=
new
ParamDefinition
(
this
,
"
N
"
,
ParamDomainValue
.
INTEGER
,
undefined
,
rN
,
ParamFamily
.
ANY
);
this
.
_N
=
new
ParamDefinition
(
this
,
"
N
"
,
ParamDomainValue
.
ANY
,
undefined
,
rN
,
ParamFamily
.
ANY
);
this
.
_Y
=
new
ParamDefinition
(
this
,
"
Y
"
,
ParamDomainValue
.
ANY
,
undefined
,
rY
,
undefined
,
false
);
this
.
addParamDefinition
(
this
.
_A
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment