Test

Aus Wiki1

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
 
(Der Versionsvergleich bezieht 30 dazwischenliegende Versionen mit ein.)
Zeile 1: Zeile 1:
-
<painting width=500 height=456>Name der Zeichnung</painting>
+
<jsxgraph box="jxgbox" width="500" height="500">
 +
        var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5,5,5,-5], axis:true});
-
<jsxgraph box="box" width="600" height="600">
+
        // Define the metal plate as a polygon
-
            var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-10, 10, 10, -10], axis:true});
+
        var polygon = board.create('polygon', [[-4,-4], [-4,4], [4,4], [4,-4]], {fillcolor:'#ddd', hasInnerPoints:true});
-
            // Create the two tanks
+
        // Define the initial temperature distribution as a function of x and y
-
            var tank1 = board.create('circle', [[-5, 0], 1], {fillcolor: '#8bc34a', strokecolor: 'black', name: 'Tank 1'});
+
        function initialTemp(x,y) {
-
             var tank2 = board.create('circle', [[5, 0], 1], {fillcolor: '#8bc34a', strokecolor: 'black', name: 'Tank 2'});
+
             return 20 + 10*Math.sin(Math.PI*x/4)*Math.sin(Math.PI*y/4);
 +
        }
-
            // Create the connecting pipe
+
        // Define the temperature function as a function of x and y and time
-
             var pipe = board.create('line', [tank1, tank2], {strokecolor: 'black', strokewidth: 2});
+
        function temp(x,y,t) {
 +
             var k = 1;
 +
            var c = 1;
 +
            var rho = 1;
 +
            var alpha = k/(rho*c);
 +
            return initialTemp(x,y) + 10*Math.exp(-alpha*Math.PI*Math.PI*t/16)*Math.sin(Math.PI*x/4)*Math.sin(Math.PI*y/4);
 +
        }
-
            // Create the heat exchanger
+
        // Create a grid of points to sample the temperature function
-
            var exchanger = board.create('polygon', [[-2, 2], [-2, -2], [2, -2], [2, 2]], {fillcolor: '#2196f3', strokecolor: 'black', name: 'Heat exchanger'});
+
        var points = [];
 +
        for (var i=-4; i<=4; i+=0.5) {
 +
            for (var j=-4; j<=4; j+=0.5) {
 +
                points.push([i,j]);
 +
            }
 +
        }
-
            // Create the heat flow arrow
+
        // Plot the temperature distribution at time t=0
-
            var arrow = board.create('arrow', [[-3, 3], [3, -3]], {strokecolor: 'red', strokewidth: 2, withLabel: true, name: 'Heat flow'});
+
        var heatmap = board.create('polygon', [points, initialTemp], {colorscheme:'greyscale', minopacity:0.5});
-
            // Create the temperature labels
+
        // Animate the temperature distribution over time
-
            var temp1 = board.create('text', [-5, -2, 'Temp 1'], {fontsize: 18});
+
        var time = 0;
-
             var temp2 = board.create('text', [5, -2, 'Temp 2'], {fontsize: 18});
+
        var dt = 0.1;
 +
        var interval = setInterval(function() {
 +
            time += dt;
 +
            var values = [];
 +
             for (var i=0; i<points.length; i++) {
 +
values.push(temp(points[i][0], points[i][1], time));
 +
    }
 +
heatmap.updateData(values);
 +
            if (time >= 2) clearInterval(interval);
 +
        }, 100);
-
            // Create the temperature sensors
 
-
            var sensor1 = board.create('point', [-5, 2], {visible: false});
 
-
            var sensor2 = board.create('point', [5, 2], {visible: false});
 
-
            // Create the temperature meters
 
-
            var meter1 = board.create('meter', [[-7, 2], [-7, 0], [-5, 0], [-5, 2]], {value: 50, label: 'Temp 1'});
 
-
            var meter2 = board.create('meter', [[7, 2], [7, 0], [5, 0], [5, 2]], {value: 50, label: 'Temp 2'});
 
-
 
-
            // Create the temperature controller
 
-
            var controller = board.create('slider', [[0, -8], [8, -8], [0, 0, 100]], {name: 'Controller'});
 
-
            controller.on('drag', function() {
 
-
                // Update the temperature meters
 
-
                var temp1 = meter1.Value() + (controller.Value() - meter2.Value()) / 10;
 
-
                var temp2 = meter2.Value() + (controller.Value() - meter1.Value()) / 10;
 
-
}
 
</jsxgraph>
</jsxgraph>

Aktuelle Version vom 10:28, 7. Apr. 2023

Persönliche Werkzeuge