Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

MATLABAssignment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Dr

 A.  Cookson     Department  of  Mechanical  Engineering  


2018/2019     University  of  Bath  
ME40064:  Systems  Modelling  &  Simulation  
ME50344:  Engineering  Systems  Simulation  
 
Assignment  2    
 
Summary  
 
In  this  coursework  you  must  extend  your  finite  element  code  to  be  able  to  solve  
the  transient  form  of  the  diffusion-­‐reaction  equation:    
 
@c @2c  
= D 2 + c + f  
@t @x  
 
You  will  then  use  this  code  to  model  the  effects  of  heat  damage  to  human  skin,  
thereby  being  able  to  estimate  the  level  of  thermal  shielding  that  a  piece  of  
protective  clothing  must  provide.  
 
Your  code  may  use  either  the  backward  Euler  or  Crank-­‐Nicolson  scheme  for  
time  integration,  but  you  must  state  which,  and  in  your  answers  to  the  following  
specific  tasks,  comment  on  any  implications  your  choice  may  have  had  on  the  
accuracy  of  your  solution.    
 
Note  that  you  may  either  re-­‐use  your  existing  functions  to  calculate  element  
matrices,  i.e.  that  represent  the  analytically  integrated  forms,  or  you  can  re-­‐write  
them  to  use  Gaussian  quadrature  to  evaluate  the  local  element  integrals.  You  
should  not  use  Matlab’s  in-­‐built  functions  for  numerical  or  symbolic  integration.  
Using  the  Gaussian  quadrature  method  in  your  code  will  attract  extra  credit.  
 
Part  1:  Software  Verification  
 
Check  that  your  code  is  working  correctly  by  solving  the  following  transient  
diffusion  equation,  for  the  domain  defined  from  x  =  0  to  1,  and  subject  to  the  
following  initial  and  Dirichlet  boundary  conditions,  and  compare  it  to  the  
analytical  solution:  
 
@c @2c
= 2
@t @x

x = [0, 1], c(x, 0) = 0, c(0, t) = 0, c(1, t) = 1  


Page 1 of 5  
 
Dr  A.  Cookson     Department  of  Mechanical  Engineering  
2018/2019     University  of  Bath  
 
In  order  to  achieve  good  accuracy  in  your  solution,  use  an  element  size  of  0.1  
(i.e.  a  10  element  mesh)  and  a  time  step,  Δt  =  0.01,  (particularly  if  you  choose  to  
use  the  Crank-­‐Nicolson  scheme).  As  shown  in  Lecture  13,  this  problem  has  the  
following  analytical  solution:  
 
1
2 X ( 1)n n2 ⇡ 2 t
c(x, t) = x + e sin(n⇡x)
⇡ n=1 n
 
 
A  Matlab  function  to  compute  this  analytical  expression,  
TransientAnalyticSoln.m, is  provided  on  Moodle.
 
Create  the  following  two  figures  to  demonstrate  that  your  code  is  correct:  
a) Plot  your  solution  c(x)  vs.  x,  showing  the  solutions  at  t  =  0.05,  0.1,  0.3,  1.0,  
in  the  format  shown  in  Lecture  13.  
b) Plot  both  the  analytical  solution  and  your  numerical  solution  at  x=0.8,  for    
t  =  0  to  1.0.  
 
Extra  credit  is  available  for  the  following  (if  used,  be  sure  to  mention  this  in  
your  report)  
-­‐ Appropriate  use  of  unit  tests  throughout  your  code  
-­‐ Testing  both  backward  Euler  and  Crank-­‐Nicolson  time  stepping  methods  
-­‐ Gaussian  quadrature  
-­‐ Implementing  quadratic  basis  functions  
-­‐ Investigating  errors  &  convergence  using  the  L2  norm  
 
Part  2:  Modelling  &  Simulation  Results  
 
1. Now  use  your  code  to  solve  the  tissue  burn  model  introduced  in  Lecture  14.  
This  has  a  governing  equation  of:  
  ✓ ◆ 2 ✓ ◆ ✓ ◆
  @T k @ T G⇢ c
b b G⇢ c
b b
  = 2
T + Tb
 
@t ⇢c @x ⇢c ⇢c
 
Note  that  you  may  find  the  backward  Euler  much  faster  than  Crank-­‐Nicolson  
for  achieving  stable  results  –  for  backward  Euler  a  time  step  of  0.005  is  likely  to  
be  sufficient  but  you  should  double-­‐check  this  for  your  solutions  and  particular  
mesh  resolution.    
 

Page 2 of 5  
 
Dr  A.  Cookson     Department  of  Mechanical  Engineering  
2018/2019     University  of  Bath  
Your  finite  element  mesh  and  material  parameters  must  represent  the  three-­‐
layered  structure  of  skin,  as  follows:  
 

 
 
Parameter  values  that  you  should  use  in  each  layer  are  provided  in  Table  1  –  
with  the  exception  that  in  this  question  we  assume  zero  blood  flow  i.e.  G=0  
everywhere.  The  layers  of  the  tissue  are  defined  at  the  following  x  
coordinates:  E=0.00166667,  D=0.005,  B=0.01.  
 
a) Run  your  code  for  the  following  initial  conditions  and  Dirichlet  boundary  
conditions,  for  a  maximum  of  50  seconds:  
 
T (x, 0) = 310.15K, T (x = B, t) = 310.15K, T (x = 0, t) = 393.15K
 
<latexit sha1_base64="S+gsjDMsRLnFMWkh0JHLvCu3rDQ=">AAACMXicdZDLSgMxFIYz9VbrbdSlm2ARKpSSsYi6KJS6Kbip0IvQDiWTpm1o5mKSEcvQV3Ljm4ibLhRx60uYmXahrR4I/PzfOZyc3wk4kwqhqZFaWV1b30hvZra2d3b3zP2DpvRDQWiD+NwXdw6WlDOPNhRTnN4FgmLX4bTljK5j3nqgQjLfq6txQG0XDzzWZwQrbXXNaj33mEensASLFipY5/AmDzv3Ie5BDUqVPFT/MZSfoatigrpmFhVQUnBZWHORBfOqdc2XTs8noUs9RTiWsm2hQNkRFooRTieZTihpgMkID2hbSw+7VNpRcvEEnminB/u+0M9TMHF/TkTYlXLsOrrTxWooF1ls/sXaoepf2hHzglBRj8wW9UMOlQ/j+GCPCUoUH2uBiWD6r5AMscBE6ZAzOgRr8eRl0TwrxHneomy5Mo8jDY7AMcgBC1yAMqiCGmgAAp7AK3gD78azMTU+jM9Za8qYzxyCX2V8fQNUE6CX</latexit>
sha1_base64="/3jbs8nrmRVJwXnYeTlBGQWw8oc=">AAACMXicdZBLS0JBFMfPtZfZ61bLNoMSGIncm0S1EMQ2QhsDX6Aic8dRB+c+mpkbifhd+gRt+ibRxkURbfsSjY9FaR0Y+PP/ncOZ83cCzqSyrLERWVldW9+Ibsa2tnd298z9g4r0Q0FomfjcFzUHS8qZR8uKKU5rgaDYdTitOv3rCa/eUyGZ75XUIKBNF3c91mEEK221zEIp+ZCyTlAWZWwrbZ+jmxRq3IW4jTTI5lNI/ces1AxdZaaoZSastDUttCzsuUjk4o3TRwAotsyXRtsnoUs9RTiWsm5bgWoOsVCMcDqKNUJJA0z6uEvrWnrYpbI5nF48QsfaaaOOL/TzFJq6PyeG2JVy4Dq608WqJxfZxPyL1UPVuWwOmReEinpktqgTcqR8NIkPtZmgRPGBFpgIpv+KSA8LTJQOOaZDsBdPXhaVs/Qkz1udRh5mFYUjiEMSbLiAHBSgCGUg8ASv8AbvxrMxNj6Mz1lrxJjPHMKvMr6+AWaSoiA=</latexit>
sha1_base64="deDdzdjGHZafshfKucR35742ZyY=">AAACMXicdZDLSgMxFIYz9VbrbdSlm9AiVBzKjEXURaHUTcFNhd6gLSWTZtrQzMUkI5bSt/A53Pgm4qYLRdz6EmamXWirBwI//3cOJ+e3A0aFNM2pllhZXVvfSG6mtrZ3dvf0/YO68EOOSQ37zOdNGwnCqEdqkkpGmgEnyLUZadjD64g37gkX1PeqchSQjov6HnUoRlJZXb1czT4Y5gkswLxl5qxzeGPA9l2IelCBQsmA8j9mGjN0lY9RV8+YOTMuuCysucgU0+3Tx2lxVOnqL+2ej0OXeBIzJETLMgPZGSMuKWZkkmqHggQID1GftJT0kEtEZxxfPIHHyulBx+fqeRLG7s+JMXKFGLm26nSRHIhFFpl/sVYoncvOmHpBKImHZ4uckEHpwyg+2KOcYMlGSiDMqforxAPEEZYq5JQKwVo8eVnUz3JRnrcqjRKYVRIcgTTIAgtcgCIogwqoAQyewCt4A+/aszbVPrTPWWtCm88cgl+lfX0Db/yjpg==</latexit>

Create  a  plot  showing  the  spatial  temperature  distribution  in  the  tissue  for  
various  points  in  time  between  0  and  50  seconds.  Explain  the  shape  of  the  
curves  as  they  change  through  time  based  on  your  knowledge  of  the  
physics,  initial  conditions,  and  boundary  conditions.  
 
b)  Once  you  have  solved  the  temperature  distribution  in  space  and  time,  use  
this  information  to  determine  the  level  of  tissue  damage  that  will  result.  To  
do  this,  evaluate  the  following  integral  numerically  at  the  mesh  node  for  x=E:  
  t Z ✓ ◆
  98 12017
  = 2 ⇥ 10 exp dt
  tburn (T 273.15)
 
<latexit sha1_base64="42sVyH86fqDkPq4E9nzrj4BTk4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rSAQhf24QscQg8EXMBP+A1/ksvkV/I3uV60LiW3M+/gXiU3/wBG5LCV</latexit>
sha1_base64="tzOz+MPQxdZIpKPAb0paT/Q1CBQ=">AAACRHicbZDPbhMxEMa9pdAS/jSFIxysVkjpodE6VZVyQKrgQI9FatpKcRp5ndnEqu1d2bOIyNpX4J248AAckLhy4dJDK8QV4SQ9QMvIlj5934w8/mWlVh7T9FuydGf57r2V1fuNBw8fPV5rrj859kXlJPRkoQt3mgkPWlnooUINp6UDYTINJ9n5m1l+8h6cV4U9wmkJAyPGVuVKCozWsNnnb4Uxgr6iXFkchniyytm6PgtY0w7lqAx4ytKz8HKvphw+lFxDjq1tnjshA+ukrFuH1tF2p7vTZrtbNXdqPMEtOsJhczNtp/OitwW7Fpv7r/Pq+fePXw+HzS98VMjKgEWphfd9lpY4CMKhkhrqBq88lEKeizH0o7QirjYIcwg1fRGdEc0LF69FOnf/ngjCeD81Wew0Aif+ZjYz/5f1K8z3BkHZskKwcvFQXmmKBZ0RpSPlQKKeRiGkU3FXKiciwsHIvREhsJtfvi2OO22Wttm7GQ2yqFXyjGyQFmGkS/bJATkkPSLJJ/KDXJKr5HNykfxMfi1al5Lrmafkn0p+/wFLQbLX</latexit>

Integrate  between  the  time  points,  tburn,  at  which  the  temperature  T  becomes  
greater  than  317.15  Kelvin,  and  time,  t  (which  will  be  50  seconds  for  all  these  
questions).    
 
Note  that  the  Matlab  function,  trapz(x),  uses  the  trapezium  rule  to  
integrate  the  vector  x,  assuming  an  interval  of  1.  Therefore  multiply  the  
output  by  the  size  of  your  timestep,  Δt,  to  obtain  the  final  value  of  this  
integral.  
 
Page 3 of 5  
 
Dr  A.  Cookson     Department  of  Mechanical  Engineering  
2018/2019     University  of  Bath  
If  Γ >  1  at  x=E,  this  produces  a  second-­‐degree  burn.  State  the  value  of  Γ  you  
have  calculated  at  this  node  (don’t  be  alarmed  if  it  is  very  large  or  small),  and  
hence  state  whether  you  expect  a  second-­‐degree  burn  to  occur.  
 
2. Now  use  your  code  to  determine  the  minimum  temperature  reduction  (to  the  
nearest  0.5  degree  C)  that  must  be  achieved  by  the  protective  clothing  at  the  
boundary  x=0,  in  order  that  second-­‐degree  burns,  as  measured  at  x=E,  are  
not  caused  by  t=50s.  State  the  final  Dirichlet  boundary  condition  at  x=0  that  
achieves  this,  and  explain  how  you  used  your  code,  and  any  other  
calculations,  to  estimate  this  value.  Include  any  data  or  figures  that  you  feel  
are  relevant  in  order  to  demonstrate  your  approach  to  estimating  this.  
 
3. Re-­‐run  your  results  for  question  2,  but  now  including  the  blood  flow  related  
reaction  &  source  terms  –  use  the  values  in  Table  1  for  each  region  of  tissue.  
How  much  does  this  change  the  temperature  distribution  in  space  and  time?  
Do  you  consider  this  to  be  an  important  effect  to  consider  for  future  
modelling  of  this  problem?  
 
4. Other  than  changing  the  geometry  to  a  3D  representation  of  the  body,  
comment  briefly  on  the  accuracy  of  the  modelling  assumptions  and  suggest  
how  these  could  be  modified  in  order  to  provide  more  realistic  results?  
 
 
Parameter   Epidermis   Dermis   Sub-­‐cutaneous  
k   25   40   20  
G   0   0.0375   0.0375  
ρ   1200   1200   1200  
c   3300   3300   3300  
ρb   -­‐   1060   1060  
cb   -­‐   3770   3770  
Tb   -­‐   310.15   310.15  
Table  1:  Parameter  values  for  questions  2,  3  and  4.  Note  that  some  are  
realistic  and  others  are  not,  having  been  chosen  to  allow  you  to  solve  your  
model  in  a  reasonable  time  frame.  

   

Page 4 of 5  
 
Dr  A.  Cookson     Department  of  Mechanical  Engineering  
2018/2019     University  of  Bath  
SUBMISSION  GUIDELINES  
 
Structure  your  report  as  a  set  of  answers  to  these  questions  –  there  is  no  
requirement  to  write  this  in  a  lab  report  format.  However  your  report  must  be  
self-­‐contained  and  therefore  must  not  assume  that  the  reader  knows  the  content  
in  this  document.    
 
• You  must  include  all  your  Matlab  source  code  as  text  in  the  Appendices.  
Do  not  paste  your  code  into  the  document  as  an  OLE  or  as  an  image.  
• Do  not  upload  zipped  or  compressed  folders  of  these  source  files.  
• Your  code  should  use  meaningful  variable  names  and  include  comments,  
in  line  with  good  practice.  
• Word  limit  of  2000  words  (not  including  source  code)  
 
Submit  your  work  using  the  online  submission  function  on  the  unit’s  Moodle  
page.  
 
Deadline:  4pm  on  Monday,  3rd  December  2018.  
 
Marks  will  be  awarded  based  on  the  following  criteria:  
 
• Correctness  of  numerical  results  
• Demonstration  of  knowledge  of  material  presented  in  the  course  including  
more  advanced  features  of  the  finite  element  method  
• Clear  presentation  of  results  
• Correctness  &  readability  of  Matlab  code  
• Level  of  insight  &  clarity  of  explanation  of  the  meaning  of  the  results  
 
 

Page 5 of 5  
 

You might also like