1. JavaScript / Говнокод #17793

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    eps=0.001;
    
    s1=new Source(1000,0.17);
    mx=new Mixer(1000);
    mb=new Mem(0.15,0.95);
    sp=new Splitter(0.80);
    s2=new Sink();
    s3=new Sink();
    
    mx.in1=s1.out1;
    mx.in2=sp.out2;
    mb.in1=mx.out1;
    sp.in1=mb.out2;
    s3.in1=sp.out1;
    s2.in1=mb.out1;
    
    for (i=0;i<50;i++){
        mx.calc();
        mb.calc();
        sp.calc();
    }
    
    function Stream(v,c){
        this.v=v||null;
        this.c=c||null;
        this.selfCheck=false;
        this.Show=function(){//how to add default values?
            return "volume="+this.v+",conc="+this.c+",selfCheck:"+this.selfCheck+"; ";
        }
    }
    
    function Source(v,c){
        this.out1=new Stream(v,c);
        this.calc=function(){};
    }
    function Sink(){
        this.in1=null;
        this.calc=function(){};
    }
    
    function Mixer(fixedV){
        this.fv=fixedV;
        this.in1=null;
        this.in2=null;
        this.out1=new Stream();
        this.calc=function(){
            this.out1.v=this.fv;//||this.in1.v+this.in2.v;
            this.in2.v=this.in2.v||0;
            this.in2.c=this.in2.c||0;
            this.in1.v=this.out1.v-this.in2.v;
            this.out1.c =(this.in1.v*this.in1.c+this.in2.v*this.in2.c)/this.out1.v;
            this.out1.selfCheck=Math.abs
            ((this.in1.v*this.in1.c+this.in2.v*this.in2.c)-(this.out1.v*this.out1.c))<eps;
        }
    }
    
    function Splitter(kS){
        this.in1=null;
        this.ks=kS||0.05;
        this.out1=new Stream();
        this.out2=new Stream();
        this.calc=function(){
            this.out1.v=this.in1.v*(1-this.ks);
            this.out2.v=this.in1.v*(this.ks);
            this.out1.c=this.in1.c;
            this.out2.c=this.in1.c;
        }
    
    }
    
    function Mem(kV,kC) {
        this.kv = kV||0.15;
        this.kc = kC||0.95;
        this.in1 = null;
        this.out1 = new Stream();
        this.out2 = new Stream();
        this.calc = function () {
            this.out1.v = this.in1.v * this.kv;
            this.out1.c = this.in1.c * (1 - this.kc);
            this.out2.v = this.in1.v * (1 - this.kv);
            this.out2.c = (this.in1.v * this.in1.c - this.out1.v * this.out1.c) / this.out2.v;
            this.out1.selfCheck = this.out2.selfCheck = Math.abs
            (this.in1.v * this.in1.c - (this.out1.v * this.out1.c + this.out2.v * this.out2.c)) < eps;
    
        }
    }

    Запостил: xtfkpi, 16 Марта 2015

    Комментарии (3) RSS

    • программа для расчета схемы химико-технологического процесса
      Ответить
    • такс такс такс што это тут у нас mem mem ахахахахах mem наканецта
      /300
      Ответить

    Добавить комментарий