楼主: ReneeBK
1597 16

【Source Code】Scientific Computing MATLAB [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4900份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49655 个
通用积分
55.9937
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57805 点
帖子
4005
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

楼主
ReneeBK 发表于 2017-2-27 08:56:59 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Scientific Computing MATLAB

Source code supporting the course "Introduction to Scientific and High Performance Computing with MATLAB" by Miguel O. Bernabeu

本帖隐藏的内容






二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Scientific computing Comput MATLAB matla supporting course

已有 1 人评分经验 收起 理由
xujingtang + 80 奖励积极上传好的资料

总评分: 经验 + 80   查看全部评分

本帖被以下文库推荐

沙发
ReneeBK 发表于 2017-2-27 08:57:48
  1. function [ systemMatrix ] = AssemblyFiniteDifferencesMatrix( problemConfiguration )
  2. %ASSEMBLYFINITEDIFFERENCESMATRIX Assembly a semi-implicit finite difference
  3. %monodomain matrix (systemMatrix) according to the problem description in
  4. %problemConfiguration.
  5. %
  6. %   systemMatrix is a tridiagonal matrix of the form
  7. %
  8. %     [a 2*b 0 ...       0]
  9. %     [b  a  b  0 ...    0]
  10. %     [0  b  a  b  0 ... 0]
  11. %     [0 ... b  a  b ... 0]
  12. %     [0 ... 0  b  a  b  0]
  13. %     [0    ... 0  b  a  b]
  14. %     [0       ... 0 2*b a]
  15. %
  16. %   with a = surfaceRatio*capacitance + 2*conductivity*timeStep/spaceStep^2,
  17. %        b = -conductivity*timeStep/spaceStep^2
  18. %
  19. %        conductivity = { leftConductivity,  if columnIndex <= (numberCells+1)/2,
  20. %                       { rightConductivity, otherwise.

  21. % Introduction to Scientific and High Performance Computing with MATLAB
  22. %
  23. % Copyright (c) 2012-2014, Miguel O. Bernabeu, All rights reserved.
  24. %
  25. % This library is free software; you can redistribute it and/or
  26. % modify it under the terms of the GNU Lesser General Public
  27. % License as published by the Free Software Foundation; either
  28. % version 3.0 of the License, or (at your option) any later version.
  29. %
  30. % This library is distributed in the hope that it will be useful,
  31. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  33. % Lesser General Public License for more details.
  34. %
  35. % You should have received a copy of the GNU Lesser General Public
  36. % License along with this library.

  37. surfaceRatioTimesCapacitance = problemConfiguration.cellSurfaceAreaToVolumeRatio * problemConfiguration.cellMembraneCapacitance;
  38. leftCondutivityTimesTimeStepOverSpaceStepSquared = problemConfiguration.leftConductivity * problemConfiguration.pdeTimeStep / problemConfiguration.spaceStep^2;
  39. rightCondutivityTimesTimeStepOverSpaceStepSquared = problemConfiguration.rightConductivity * problemConfiguration.pdeTimeStep / problemConfiguration.spaceStep^2;

  40. assert(problemConfiguration.numberCells > 1, 'Minimum problem size is currently 2');

  41. systemMatrix = zeros(problemConfiguration.numberCells);

  42. % First matrix row
  43. systemMatrix(1,1) = surfaceRatioTimesCapacitance + 2*leftCondutivityTimesTimeStepOverSpaceStepSquared;
  44. systemMatrix(1,2) = -2*leftCondutivityTimesTimeStepOverSpaceStepSquared;

  45. % Rows 2 to numberCells-1
  46. for rowIndex = 2:problemConfiguration.numberCells-1
  47.     % Determine which conductivity to use (left half or right half)
  48.     if rowIndex <= (problemConfiguration.numberCells+1)/2
  49.         condutivityTimesTimeStepOverSpaceStepSquared = leftCondutivityTimesTimeStepOverSpaceStepSquared;
  50.     else
  51.         condutivityTimesTimeStepOverSpaceStepSquared = rightCondutivityTimesTimeStepOverSpaceStepSquared;
  52.     end
  53.    
  54.     systemMatrix(rowIndex,rowIndex-1) = -condutivityTimesTimeStepOverSpaceStepSquared;
  55.     systemMatrix(rowIndex,rowIndex) = surfaceRatioTimesCapacitance + 2*condutivityTimesTimeStepOverSpaceStepSquared;
  56.     systemMatrix(rowIndex,rowIndex+1) = -condutivityTimesTimeStepOverSpaceStepSquared;
  57. end

  58. % Last matrix row
  59. systemMatrix(problemConfiguration.numberCells,problemConfiguration.numberCells-1) = -2*rightCondutivityTimesTimeStepOverSpaceStepSquared;
  60. systemMatrix(problemConfiguration.numberCells,problemConfiguration.numberCells) = surfaceRatioTimesCapacitance + 2*rightCondutivityTimesTimeStepOverSpaceStepSquared;

  61. systemMatrix = sparse(systemMatrix);

  62. end
复制代码

藤椅
ReneeBK 发表于 2017-2-27 09:00:57
  1. % Work out current time based on time step number
  2. currentTime = problemConfiguration.pdeTimeStep*(timeStepNumber-1);

  3. % Initialise stimuli vector to zero
  4. stimuli = zeros(problemConfiguration.numberCells, 1);

  5. % If its time to do it, stimulate two cells in the middle of the domain
  6. if (currentTime>=problemConfiguration.stimulusStart && currentTime<problemConfiguration.stimulusStart+problemConfiguration.stimulusDuration)
  7.     stimuli(floor(problemConfiguration.numberCells/2) : floor(problemConfiguration.numberCells/2) + 1) = problemConfiguration.stimulusMagnitude;
  8. end

  9. end
复制代码

板凳
ReneeBK 发表于 2017-2-27 09:02:34
  1. function RegressionTest( problemConfiguration, conductionVelocities )
  2. %REGRESSIONTEST This function checks the output of a simulation with 50
  3. %cells and conductivities of 1.4 mS/cm against some known conduction
  4. %velocity results

  5. recordedConductionVelocity = 0.0521720;

  6. if (problemConfiguration.numberCells==50 && problemConfiguration.leftConductivity==1.4 && problemConfiguration.rightConductivity==1.4)
  7.    if any(conductionVelocities == Inf)
  8.        warning('The simulation was not run for long enough to compute conduction velocities. Regression test could not to be performed.');
  9.        return;
  10.    end
  11.    if any(abs(conductionVelocities - recordedConductionVelocity)>1e-4)
  12.        error('Regression test failed. You may have introduced a bug while optimising the code! Review your last changes.');
  13.    end
  14. end

  15. end
复制代码

报纸
wenyu 发表于 2017-2-27 09:12:14
kkkkkkkk

地板
igs816 在职认证  发表于 2017-2-27 09:15:52
书么?

7
tbs20 发表于 2017-2-27 09:29:56

8
fengyg 企业认证  发表于 2017-2-27 10:05:15
kankan

9
heinrico 在职认证  发表于 2017-2-27 10:19:40
thanking you....

10
franky_sas 发表于 2017-2-27 10:48:06

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-19 05:37