Skip to content

Instantly share code, notes, and snippets.

@mik30s
Created September 7, 2018 02:57
Show Gist options
  • Save mik30s/860e974a93ff4ae17db3eb8e841a2f95 to your computer and use it in GitHub Desktop.
Save mik30s/860e974a93ff4ae17db3eb8e841a2f95 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Copy of Untitled0.ipynb",
"version": "0.3.2",
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"metadata": {
"id": "P3xw85kaTOMT",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1581
},
"outputId": "f1ff14a6-687b-4d80-b5b1-5d39003781fc"
},
"cell_type": "code",
"source": [
"import math\n",
"\n",
"import numpy as np\n",
"\n",
"from matplotlib import pyplot as plt\n",
"\n",
"def differentialEquation(f,t):\n",
"\n",
" \"this is the differential equation that will generate the DF\"\n",
"\n",
" return 0.3*((750-f)/750)*f\n",
" ##return t + f**2\n",
"\n",
"fStart =420\n",
"tStart = 0\n",
" \n",
"tStop = 9\n",
"dt = 0.1\n",
"\n",
"fOld = fStart\n",
"tOld = tStart\n",
"print(tOld,fOld)\n",
"\n",
"\n",
"while tOld <= tStop:\n",
" df = differentialEquation(fOld,tOld)\n",
" fNew = fOld + dt*df\n",
" tNew = tOld + dt\n",
" print(tNew,fNew)\n",
" tOld = tNew\n",
" fOld = fNew\n"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"0 420\n",
"0.1 425.544\n",
"0.2 431.06681216256\n",
"0.30000000000000004 436.56607266551714\n",
"0.4 442.0394574133789\n",
"0.5 447.4846858593677\n",
"0.6 452.8995246720024\n",
"0.7 458.28179123423746\n",
"0.7999999999999999 463.62935696419015\n",
"0.8999999999999999 468.94015044755474\n",
"0.9999999999999999 474.2121603729104\n",
"1.0999999999999999 479.44343826227595\n",
"1.2 484.63210099043414\n",
"1.3 489.7763330877311\n",
"1.4000000000000001 494.8743888222484\n",
"1.5000000000000002 499.9245940584281\n",
"1.6000000000000003 504.9253478904016\n",
"1.7000000000000004 509.87512404942396\n",
"1.8000000000000005 514.7724720859301\n",
"1.9000000000000006 519.6160183278096\n",
"2.0000000000000004 524.40446661753\n",
"2.1000000000000005 529.1365988317193\n",
"2.2000000000000006 533.8112751877429\n",
"2.3000000000000007 538.4274343426727\n",
"2.400000000000001 542.9840932908395\n",
"2.500000000000001 547.4803470668896\n",
"2.600000000000001 551.915368261917\n",
"2.700000000000001 556.288406360827\n",
"2.800000000000001 560.5987869095931\n",
"2.9000000000000012 564.8459105215005\n",
"3.0000000000000013 569.029251731831\n",
"3.1000000000000014 573.1483577107264\n",
"3.2000000000000015 577.202846844188\n",
"3.3000000000000016 581.1924071933122\n",
"3.4000000000000017 585.1167948419453\n",
"3.5000000000000018 588.9758321429592\n",
"3.600000000000002 592.7694058733084\n",
"3.700000000000002 596.4974653079319\n",
"3.800000000000002 600.1600202224183\n",
"3.900000000000002 603.757138834156\n",
"4.000000000000002 607.2889456914523\n",
"4.100000000000001 610.7556195198345\n",
"4.200000000000001 614.1573910344272\n",
"4.300000000000001 617.4945407269714\n",
"4.4 620.767396635676\n",
"4.5 623.9763321057129\n",
"4.6 627.1217635477603\n",
"4.699999999999999 630.204148201583\n",
"4.799999999999999 633.2239819112112\n",
"4.899999999999999 636.181796917848\n",
"4.999999999999998 639.0781596761985\n",
"5.099999999999998 641.9136686994798\n",
"5.1999999999999975 644.6889524379352\n",
"5.299999999999997 647.4046671952524\n",
"5.399999999999997 650.0614950868621\n",
"5.4999999999999964 652.6601420436854\n",
"5.599999999999996 655.2013358644966\n",
"5.699999999999996 657.6858243196867\n",
"5.799999999999995 660.1143733088347\n",
"5.899999999999995 662.4877650741431\n",
"5.999999999999995 664.8067964714501\n",
"6.099999999999994 667.0722773002083\n",
"6.199999999999994 669.2850286935151\n",
"6.299999999999994 671.4458815689893\n",
"6.399999999999993 673.5556751410207\n",
"6.499999999999993 675.6152554946643\n",
"6.5999999999999925 677.6254742212194\n",
"6.699999999999992 679.5871871153147\n",
"6.799999999999992 681.5012529331219\n",
"6.8999999999999915 683.3685322111389\n",
"6.999999999999991 685.1898861448168\n",
"7.099999999999991 686.9661755261554\n",
"7.19999999999999 688.6982597392588\n",
"7.29999999999999 690.3869958127212\n",
"7.39999999999999 692.0332375276103\n",
"7.499999999999989 693.6378345797207\n",
"7.599999999999989 695.2016317946945\n",
"7.699999999999989 696.7254683945351\n",
"7.799999999999988 698.2101773139879\n",
"7.899999999999988 699.6565845652143\n",
"7.999999999999988 701.0655086491523\n",
"8.099999999999987 702.4377600119271\n",
"8.199999999999987 703.774140544662\n",
"8.299999999999986 705.0754431250268\n",
"8.399999999999986 706.3424511988595\n",
"8.499999999999986 707.5759384002008\n",
"8.599999999999985 708.7766682080899\n",
"8.699999999999985 709.9453936384862\n",
"8.799999999999985 711.0828569697005\n",
"8.899999999999984 712.1897894997438\n",
"8.999999999999984 713.2669113340286\n",
"9.099999999999984 714.3149312018901\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "BJQghpt9aqFl",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment