1 / 35

A Core Course on Modeling

A Core Course on Modeling. Week 4 – The Function of Functions. Examples street lanterns planets and gravity. A Core Course on Modeling. Week 4 – The Function of Functions. Street Lanterns. 2. image: http://www.westberks.gov.uk/index.aspx?articleid=3785. A Core Course on Modeling.

jalila
Download Presentation

A Core Course on Modeling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Core Course on Modeling Week 4 – The Function of Functions • Examples • street lanterns • planets and gravity

  2. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 2 image: http://www.westberks.gov.uk/index.aspx?articleid=3785

  3. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 3 Purpose: • how much energy is needed to illuminate road • intensity everywhere is between acceptable borders Interesting quantities: • totPower • maxInt • minInt

  4. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 4 Purpose: • how much energy is needed to illuminate road • intensity everywhere is between acceptable borders Interesting quantities: • totPower • maxInt • minInt simple: totPower = nLanterns * p not so simple …

  5. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 5 dL lW roadWidth roadLength h (i,j) j i

  6. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 6 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns dL lW roadWidth roadLength h j i

  7. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 7 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns maxInt=#(i,slices , maxIntensityInSlice(i), max) maxIntensityInSlice(i)=#(j,cellsInSlice(i),cellInt(i,j),max) cellInt(i,j)=lfG(i,j) =lfG[i][j]

  8. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 8 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns maxInt=#(i,slices ,#(j,cellsInSlice(i),cellInt(i,j) ,max),max) maxIntensityInSlice(i)=#(j,cellsInSlice(i),cellInt(i,j),max) cellInt(i,j)=lfG(i,j) =lfG[i][j]

  9. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 9 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns maxInt=#(i,slices ,#(j,cellsInSlice(i),lfG[i][j], max),max) maxIntensityInSlice(i)=#(j,cellsInSlice(i),cellInt(i,j),max) cellInt(i,j)=lfG(i,j) =lfG[i][j]

  10. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 10 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns maxInt=#(i,slices ,#(j,cellsInSlice(i),lfG[i][j], max),max) slices: lfG consists of slices; vDom('domain') gives the sequence of indices of an aggregation e.g., vDom(['a','b','c','d'])=[0,1,2,3], vDom(['x':17,'y':1])=['x','y'] so:slices = vDom(lfG), andcellsInSlice(i)=vDom(lfG[i])

  11. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 11 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns maxInt=#(i,vDom(lfG),#(j,cellsInSlice(i),lfG[i][j], max),max) slices: lfG consists of slices; vDom('domain') gives the sequence of indices of an aggregation e.g., vDom(['a','b','c','d'])=[0,1,2,3], vDom(['x':17,'y':1])=['x','y'] so:slices = vDom(lfG),andcellsInSlice(i)=vDom(lfG[i])

  12. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 12 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns maxInt=#(i,vDom(lfG),#(j,vDom(lfG[i]), lfG[i][j], max),max) slices: lfG consists of slices; vDom('domain') gives the sequence of indices of an aggregation e.g., vDom(['a','b','c','d'])=[0,1,2,3], vDom(['x':17,'y':1])=['x','y'] so:slices = vDom(lfG) andcellsInSlice(i)=vDom(lfG[i])

  13. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 13 totPower = nLanterns * p maxInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],max),max) minInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],min),min)

  14. j i A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 14 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns Defining lfG : lfG=#(i,slices,lumSlice(i),vAppend) E.g., vAppend([10,20,30],40)=[10,20,30,40] E.g., vAppend(vAppend([],[40,50]),[60,70])=[[40,50],[60,70]] so: lfG=[lumSlice(0),lumSlice(1),lumSlice(2),…] lumSlice(i) is a function that produces the i-th luminated slice

  15. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 15 totPower = nLanterns * p maxInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],max),max) minInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],min),min) lfG=#(i,vSequence(0,roadWidth),lumSlice(i),vAppend)

  16. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 16 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns Defining lumSlice(i) : lumSlice(i)=#(j,cellsPerSlice,lumAll(i,j),vAppend) lumAll(i,j) is a function that produces the illumination of cell (i,j), due to 'all' lanterns j i

  17. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 17 totPower = nLanterns * p maxInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],max),max) minInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],min),min) lfG=#(i,vSequence(0,roadWidth),lumSlice(i),vAppend) lumSlice(w)=#(l,vSequence(0,roadLength),lumAll(w,l),vAppend)

  18. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 18 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns Defining lumAll(w,l) : lumAll(w,l)=#(n,allContributingLanterns,lum(w,l,n),add) lum(w,l,n) is a function that produces the illumination of cell (i,j)=(w,l), due to lantern nr. n

  19. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 19 totPower = nLanterns * p maxInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],max),max) minInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],min),min) lfG=#(i,vSequence(0,roadWidth),lumSlice(i),vAppend) lumSlice(w)=#(l,vSequence(0,roadLength),lumAll(w,l),vAppend) lumAll(w,l)=#(n,vSequence(-1,nLanterns),lum(w,l,n),add)

  20. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 20 lfG: aggregation of slices slice: aggregation of cells (i=const) cell: receives light from all lanterns Defining lum(w,l,n): lum(w,l,n)=p/(h*h+pow(abs(l-n*dL),2)+pow(abs(w-lW),2)) w - lW l - n dL h image: http://www.ph.unimelb.edu.au/~ddolce/

  21. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 21 totPower = nLanterns * p maxInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],max),max) minInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],min),min) lfG=#(i,vSequence(0,roadWidth),lumSlice(i),vAppend) lumSlice(w)=#(l,vSequence(0,roadLength),lumAll(w,l),vAppend) lumAll(w,l)=#(n,vSequence(-1,nLanterns),lum(w,l,n),add) lum(w,l,n)=p/(h*h+pow(abs(l-n*dL),2)+pow(abs(w-lW),2))

  22. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 22 totPower = nLanterns * p maxInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],max),max) minInt=#(i,vDom(lfG),#(j,vDom(lfG[i]),lfG[i][j],min),min) lfG=#(i,vSequence(0,roadWidth),lumSlice(i),vAppend) lumSlice(w)=#(l,vSequence(0,roadLength),lumAll(w,l),vAppend) lumAll(w,l)=#(n,vSequence(-1,nLanterns),lum(w,l,n),add) lum(w,l,n)=p/(h*h+pow(abs(l-n*dL),2)+pow(abs(w-lW),2)) dL=slider(25,5,50) h=slider(5,1.5,30) p=slider(200,100,2000) roadLength=40 roadWidth=10 lW=roadWidth/2 nLanterns=1+roadLength/dL

  23. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 23 http://www.opencourse.info/astronomy/introduction/05.motion_planets/

  24. A Core Course on Modeling Week 4 – The Function of Functions Street Lanterns 24 Purpose: • analyse the motions of planets Interesting quantities: • for each planet, its location r = ['x':xlocation,'y':ylocation] as it develops over time

  25. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 25 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) r = r{1} + v * dt if time > 1 = initial locations if time  1 So r=[['x': ..,'y': …], ['x': ..,'y': …], ['x': ..,'y': …], …] and v=[['x': ..,'y': …], ['x': ..,'y': …], ['x': ..,'y': …], …]

  26. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 26 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) v = v{1} + a * dt if time > 1 = initial velocities if time  1 So v=[['x': ..,'y': …], ['x': ..,'y': …], ['x': ..,'y': …], …] and a=[['x': ..,'y': …], ['x': ..,'y': …], ['x': ..,'y': …], …]

  27. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 27 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) F = ma, so a = F/m Since a is a vector, F and m must be vectors with same amount of elements. Every element of F is a ['x': …, 'y': …] vector; every element of m is a number, so every element of a is a [ 'x': …, 'y': …] vector.

  28. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 28 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i) is the force on planet nr i. Forces (=vectors ['x': …, 'y': …] are appended, i.e. combined into a vector-of-vectors: [['x': …, 'y': …], ['x': ..., 'y': …], ['x': …,'y': …] , …]

  29. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 29 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i)=#(j,vSequence(0,5),if(i!=j,newton(i,j),0),add) forceOnePlanet(i) is the calculated as the sum of gravity forces newton(i,j). Notice: only calculate force between 2 different planets: i != j

  30. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 30 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i)=#(j,vSequence(0,5),if(i!=j,newton(i,j),0),add) newton(i,j)=g*m[i]*m[j]*distVec(i,j)/(pow(vNormEuclid(distVec(i,j)),3)) vNormEuclid(a)=i ai2 mi mj Gravity force: Fij = g mi mj / ||ri - rj||2, directed along ri – rj. So: Fij = g mi mj (ri – rj) / ||ri – rj||3

  31. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 31 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i)=#(j,vSequence(0,5),if(i!=j,newton(i,j),0),add) newton(i,j)=g*m[i]*m[j]*distVec(i,j)/(pow(vNormEuclid(distVec(i,j)),3)) distVec(i,j)=r{1}[j]-r{1}[i] distVec(i,j) is the vector pointing from planet i to planet j, taken at the previous time step to ensure Qcurr = F ( Qprev, Pprev) (see week 3!)

  32. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 32 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i)=#(j,vSequence(0,5),if(i!=j,newton(i,j),0),add) newton(i,j)=g*m[i]*m[j]*distVec(i,j)/(pow(vNormEuclid(distVec(i,j)),3)) distVec(i,j)=r{1}[j]-r{1}[i] time=if(!but,time{1}+1,0) If but is false (i.e., button is not pressed), time proceeds. Otherwise time is reset to 0.

  33. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 33 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i)=#(j,vSequence(0,5),if(i!=j,newton(i,j),0),add) newton(i,j)=g*m[i]*m[j]*distVec(i,j)/(pow(vNormEuclid(distVec(i,j)),3)) distVec(i,j)=r{1}[j]-r{1}[i] time=if(!but,time{1}+1,0) but=button() button() is an ACCEL standard function to create a button; return TRUE if the button is clicked, else FALSE.

  34. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 34 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i)=#(j,vSequence(0,5),if(i!=j,newton(i,j),0),add) newton(i,j)=g*m[i]*m[j]*distVec(i,j)/(pow(vNormEuclid(distVec(i,j)),3)) distVec(i,j)=r{1}[j]-r{1}[i] time=if(!but,time{1}+1,0) but=button() g=slider(0.002,0,0.01) The gravity force is controlled interactively with a slider.

  35. A Core Course on Modeling Week 4 – The Function of Functions Planets and Gravity 35 r=cond(time>1,r{1}+v*dt,[['x':0,'y':0],['x':15,'y':0],['x':7,'y':10],['x':-7,'y':-10],['x':-15,'y':0]]) v=cond(time>1,v{1}+a*dt,[['x':0,'y':0],['x':0,'y':0.1],['x':-0.05,'y':0.03],['x':0.05,'y':-0.03],['x':0,'y':-0.1]]) a=cond(time>1,f/m,0) f=#(i,vSequence(0,5),forceOnePlanet(i),vAppend) forceOnePlanet(i)=#(j,vSequence(0,5),if(i!=j,newton(i,j),0),add) newton(i,j)=g*m[i]*m[j]*distVec(i,j)/(pow(vNormEuclid(distVec(i,j)),3)) distVec(i,j)=r{1}[j]-r{1}[i] time=if(!but,time{1}+1,0) but=button() g=slider(0.002,0,0.01) plotResult=plot([['plotType:bubble,x:{mode:data,ref:1},y:{mode:data,ref:2},diameter:{mode:data,ref:3}',50+@(vTranspose(r),'x'),50+@(vTranspose(r),'y'),5*pow(m,1/3)]]) m=[80,2,2,2,2] dt=1 … the rest is details ...

More Related