-
Notifications
You must be signed in to change notification settings - Fork 1
/
atom.xml
295 lines (171 loc) · 96.9 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>ChenYu-K</title>
<subtitle>楓</subtitle>
<link href="https://www.chenyu-k.com/atom.xml" rel="self"/>
<link href="https://www.chenyu-k.com/"/>
<updated>2021-11-24T09:01:30.099Z</updated>
<id>https://www.chenyu-k.com/</id>
<author>
<name>Chen Yu</name>
</author>
<generator uri="https://hexo.io/">Hexo</generator>
<entry>
<title>如何使用CUDA对abaqus进行加速</title>
<link href="https://www.chenyu-k.com/2021/11/20/2021-11-20-use-cuda-in-abaqus/"/>
<id>https://www.chenyu-k.com/2021/11/20/2021-11-20-use-cuda-in-abaqus/</id>
<published>2021-11-20T06:01:24.000Z</published>
<updated>2021-11-24T09:01:30.099Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><p>本文介绍了如何使用 <a href="https://developer.nvidia.com/zh-cn/cuda-toolkit">Nvidia CUDA</a><sup id="fnref:1"><a href="#fn:1" rel="footnote"><span class="hint--top hint--error hint--medium hint--rounded hint--bounce" aria-label="Nvidia Cuda 适用于类似于`RTX` or `Quardo`之类的 计算卡,一般的 `Geforce` 显卡不不推荐使用CUDA加速。 ">[1]</span></a></sup>的加速功能,使Abaqus计算加速。</p><span id="more"></span><p>驱动都设置完成可直接查看查看 <a href="#%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE">环境变量设置</a></p><h1 id="安装显卡">1. 安装显卡¶</h1><hr><p>提前查询好主板是否与显卡兼容,在购买显卡。<br>本次使用的是Nvidia 2021 新推出的 RTX A4000显卡<sup id="fnref:2"><a href="#fn:2" rel="footnote"><span class="hint--top hint--error hint--medium hint--rounded hint--bounce" aria-label="[官网介绍](https://www.nvidia.com/en-us/design-visualization/rtx-a4000/) ,购入金额15万日元。 ">[2]</span></a></sup>。</p><table><thead><tr><th>GPU特性</th><th>RTX A000</th></tr></thead><tbody><tr><td>GPU显存</td><td>带纠错码ECC DDR6 16GB</td></tr><tr><td>显存带宽</td><td>448GB/s</td></tr><tr><td>图形总线</td><td>PCI-E X16</td></tr><tr><td>CUDA核心数</td><td>6144</td></tr><tr><td>单精度浮点计算</td><td>19.2 TFLOPS</td></tr></tbody></table><p>*具体可参考 <a href="https://www.nvidia.cn/content/dam/en-zz/Solutions/gtcs21/rtx-a4000/nvidia-rtx-a4000-datasheet.pdf">A4000规格书</a></p><ol><li>插入卡槽</li><li>连接显卡电源(6Pin)</li><li>开机测试</li></ol><h1 id="安装显卡驱动">2. 安装显卡驱动¶</h1><hr><p>在<a href="https://www.nvidia.co.jp/Download/index.aspx?lang=jp">Nvida显卡驱动官网</a>找到合适自己的显卡驱动下载,并重启。<br><img src="https://i.imgur.com/ylSk04C.png" alt></p><h1 id="安装CUDA-工具">3. 安装CUDA 工具¶</h1><hr><p><a href="https://developer.nvidia.com/zh-cn/cuda-toolkit">CUDA工具包安装地址</a></p><p><img src="https://i.imgur.com/KgAsN7K.png" alt></p><p>CUDA的安装需要较长时间,属于正常情况。</p><h1 id="环境变量设置">4. 环境变量设置¶</h1><hr><p>在这里有两种方法可以开启CUDA的加速</p><h2 id="直接编辑系统环境变量,如下图">4.1. 直接编辑系统环境变量,如下图¶</h2><p>在系统全局变量里加入</p><table><thead><tr><th>环境变量</th><th>内容</th></tr></thead><tbody><tr><td>变量名</td><td><code>ABA_ACCELERATOR_TYPE</code></td></tr><tr><td>值</td><td><code>PLATFORM_CUDA</code></td></tr></tbody></table><p><img src="https://i.imgur.com/xEUpwAm.png" alt></p><h2 id="编辑abaqus-v6-env">4.2. 编辑abaqus_v6.env¶</h2><p>在<code>abaqus_v6.env</code><sup id="fnref:3"><a href="#fn:3" rel="footnote"><span class="hint--top hint--error hint--medium hint--rounded hint--bounce" aria-label="`abaqus_v6.env`的路径一般是在`C:\SIMULIA\EstProducts\2020\win_b64\SMA\site`这里。">[3]</span></a></sup>文件的句末加上</p> <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">os.environ["ABA_ACCELERATOR_TYPE"]="PLATFORM_CUDA" # Nvidia</span><br></pre></td></tr></table></figure><p>的字段使其可以使用CUDA加速工具加速ABAQUS。</p><p><img src="https://i.imgur.com/6Ui3AIK.png" alt></p><h1 id="是否加速成功">5. 是否加速成功¶</h1><hr><p>成功加速Abaqus反馈的Log里面会出现如下加速成功的字符。<br><img src="https://i.imgur.com/WZRgoEt.png" alt></p><h1 id="Reference">6. Reference¶</h1><div id="footnotes"><hr><div id="footnotelist"><ol style="list-style: none; padding-left: 0; margin-left: 40px"><li id="fn:1"><span style="display: inline-block; vertical-align: top; padding-right: 10px; margin-left: -40px">1.</span><span style="display: inline-block; vertical-align: top; margin-left: 10px;">Nvidia Cuda 适用于类似于<code>RTX</code> or <code>Quardo</code>之类的 计算卡,一般的 <code>Geforce</code> 显卡不不推荐使用CUDA加速。<a href="#fnref:1" rev="footnote"> ↩</a></span></li><li id="fn:2"><span style="display: inline-block; vertical-align: top; padding-right: 10px; margin-left: -40px">2.</span><span style="display: inline-block; vertical-align: top; margin-left: 10px;"><a href="https://www.nvidia.com/en-us/design-visualization/rtx-a4000/">官网介绍</a> ,购入金额15万日元。<a href="#fnref:2" rev="footnote"> ↩</a></span></li><li id="fn:3"><span style="display: inline-block; vertical-align: top; padding-right: 10px; margin-left: -40px">3.</span><span style="display: inline-block; vertical-align: top; margin-left: 10px;"><code>abaqus_v6.env</code>的路径一般是在<code>C:\SIMULIA\EstProducts\2020\win_b64\SMA\site</code>这里。<a href="#fnref:3" rev="footnote"> ↩</a></span></li></ol></div></div>]]></content>
<summary type="html"><p>本文介绍了如何使用 <a href="https://developer.nvidia.com/zh-cn/cuda-toolkit">Nvidia CUDA</a><sup id="fnref:1"><a href="#fn:1" rel="footnote"><span class="hint--top hint--error hint--medium hint--rounded hint--bounce" aria-label="Nvidia Cuda 适用于类似于`RTX` or `Quardo`之类的 计算卡,一般的 `Geforce` 显卡不不推荐使用CUDA加速。
">[1]</span></a></sup>的加速功能,使Abaqus计算加速。</p></summary>
<category term="ABAQUS" scheme="https://www.chenyu-k.com/tags/ABAQUS/"/>
</entry>
<entry>
<title>Centos7 update php5 to php7.2</title>
<link href="https://www.chenyu-k.com/2021/11/15/2021-11-15-centos-7-update-php5-to-php7-2/"/>
<id>https://www.chenyu-k.com/2021/11/15/2021-11-15-centos-7-update-php5-to-php7-2/</id>
<published>2021-11-15T04:48:29.000Z</published>
<updated>2021-11-15T04:59:25.853Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><p>In order to update to the recommended php version for wordpress,i update the original php 5.4 to php 7.2.</p><ul><li>check the list of installable php versions in yum.</li></ul><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># yum provides php</span></span><br></pre></td></tr></table></figure><ul><li>To start upgrading the PHP update source, and remove the old php.</li></ul><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm </span></span><br><span class="line"><span class="comment"># rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm</span></span><br><span class="line"><span class="comment"># yum remove php-common -y</span></span><br><span class="line"><span class="comment"># yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring php72w-pdo php72w-pgsql</span></span><br></pre></td></tr></table></figure><span id="more"></span><ul><li>check the php version.</li></ul><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># php -v</span></span><br><span class="line">PHP 7.2.34 (cli) (built: Oct 1 2020 13:37:37) ( NTS )</span><br><span class="line">Copyright (c) 1997-2018 The PHP Group</span><br><span class="line">Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies</span><br><span class="line"> with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies</span><br></pre></td></tr></table></figure><ul><li>install the php-fem</li></ul><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># yum install php72w-fpm</span></span><br><span class="line"><span class="comment"># systemctl start php-fpm.service</span></span><br><span class="line"><span class="comment"># systemctl enable php-fpm.service</span></span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><p>In order to update to the recommended php version for wordpress,i update the original php 5.4 to php 7.2.</p>
<ul>
<li>check the list of installable php versions in yum.</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># yum provides php</span></span><br></pre></td></tr></table></figure>
<ul>
<li>To start upgrading the PHP update source, and remove the old php.</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm </span></span><br><span class="line"><span class="comment"># rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm</span></span><br><span class="line"><span class="comment"># yum remove php-common -y</span></span><br><span class="line"><span class="comment"># yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring php72w-pdo php72w-pgsql</span></span><br></pre></td></tr></table></figure></summary>
<category term="linux" scheme="https://www.chenyu-k.com/tags/linux/"/>
</entry>
<entry>
<title>Centos 7.X use yum to install-php5.6.X</title>
<link href="https://www.chenyu-k.com/2021/11/12/2021-11-12-install-php5-6-X/"/>
<id>https://www.chenyu-k.com/2021/11/12/2021-11-12-install-php5-6-X/</id>
<published>2021-11-12T11:55:07.000Z</published>
<updated>2021-11-15T04:58:07.397Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><ol><li>Check now php package</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum list installed | grep php</span><br></pre></td></tr></table></figure><ol start="2"><li>if there have any php, deleate it first.</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64 </span><br></pre></td></tr></table></figure><span id="more"></span><ol start="3"><li>Configure EPEL source</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">yum install -y epel-release</span><br><span class="line">wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo</span><br></pre></td></tr></table></figure><ol start="4"><li>Configure remi source</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm</span><br></pre></td></tr></table></figure><ol start="5"><li>Install php5.6.x</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof</span><br></pre></td></tr></table></figure><ol start="6"><li>install php-fpm</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm </span><br></pre></td></tr></table></figure><ol start="7"><li>Configure boot service</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart php-fpm</span><br><span class="line">systemctl enable php-frm</span><br></pre></td></tr></table></figure><ol start="8"><li>Check if the installation is successful</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ps -ef | grep php</span><br><span class="line">netstat -anp | grep 9000</span><br></pre></td></tr></table></figure><ol start="9"><li>restar service</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl restart httpd</span><br><span class="line">sudo systemctl restart php-fpm</span><br><span class="line">service httpd restart</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><ol>
<li>Check now php package</li>
</ol>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum list installed | grep php</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>if there have any php, deleate it first.</li>
</ol>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64 </span><br></pre></td></tr></table></figure></summary>
<category term="linux" scheme="https://www.chenyu-k.com/tags/linux/"/>
</entry>
<entry>
<title>win11拖拽BUG解决方案</title>
<link href="https://www.chenyu-k.com/2021/10/28/2021-10-28-win11-bug/"/>
<id>https://www.chenyu-k.com/2021/10/28/2021-10-28-win11-bug/</id>
<published>2021-10-28T07:57:53.000Z</published>
<updated>2021-10-28T08:10:51.846Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="strange-lag-on-dragging-windows-around">1. strange lag on dragging windows around¶</h1><hr><p>A somewhat niche occurrence that a handful of users anre seeing, is pointer gost effect <font color="red">when dragging some windows around</font>. <br><br>the lag doesn’t ook to be a bug with Windows 11 directly, as the author of one post notes “i noteced that the lag only started when the window overlapped with the task bar. This made me remember that i have open shell installed. Uninstalling this fixed the issue.” <br><br>It seems Windows 11 isn’t a compbatible with some taskbar-chaing software you might be runging on windows 10 anyway, so just make sure to double check before installing.</p><h2 id="修复方式">1.1. 修复方式¶</h2><hr><p>window11 拖拽延迟问题很有可能是因为文件夹管理软件得不兼容造成。 当关闭文件夹,或者让文件夹不和任何窗口重叠就不会发生类似问题。<br><br>这里,我因为下载了<code>QTTabBar</code>,所以出现了拖拽延迟,卸载它,或者安装它最新支持win11的版本,可以解决问题。<br></p><h2 id="其他解决方案">1.2. 其他解决方案¶</h2><hr><p>类似的拖拽延迟,网络上解决方案有很多,汇总起来大概是:</p><ul><li>调低鼠标回报率</li><li>关闭窗口透明</li><li>关闭性能显示效果</li><li>跟新显卡驱动</li></ul>]]></content>
<summary type="html"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="strange-lag-on-dragging-windows-a</summary>
<category term="system" scheme="https://www.chenyu-k.com/tags/system/"/>
</entry>
<entry>
<title>Material_test-data-processing</title>
<link href="https://www.chenyu-k.com/2021/08/24/2021-08-24-Material-test/"/>
<id>https://www.chenyu-k.com/2021/08/24/2021-08-24-Material-test/</id>
<published>2021-08-24T09:23:25.000Z</published>
<updated>2021-11-24T07:08:13.849Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="材料試験自動データ処理">1. 材料試験自動データ処理¶</h1><hr><p><a href="/lang/material-test/">中文</a></p><p>鋼材の材料試験の自動化データ処理スクリプト.<br><br>実現できる機能は 降伏点,引張強度の算出.ヤング率,ポアソン比の算出.最後に,自動でグラフを出力,レポートとしてExcelに保存する.</p><div class="img-x"><img height=" 20 " width=" 20 " src=" https://cdn.jsdelivr.net/npm/simple-icons@v5/icons/googlecolab.svg "> <img height=" 20 " width=" 20 " src=" https://cdn.jsdelivr.net/npm/simple-icons@v5/icons/jupyter.svg "></div><blockquote><p><i class="fab fa-google-drive"></i> Google colab ソースコード<a href="https://colab.research.google.com/drive/1ED1jSNf7LIF0wjTKKv-pL2neszNev9Gs?usp=sharing">source_code</a></p></blockquote><span id="more"></span><script src="https://gist.github.com/ChenYu-K/1e1d40352924237fd8f503b637983d3b.js"></script><h2 id="導入">1.1. 導入¶</h2><hr><p>最初はcsv生データから,必要なデータを読み取り,応力,縦ひずみ平均値と横ひずみ平均値を算出する.</p><blockquote><p>ここでは,生データのひずみチャンネル配置によらず,コードで数値の[+,-]を用いて,縦ひずみや横ひずみの判定を行った.</p></blockquote><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> glob <span class="keyword">import</span> glob</span><br><span class="line"><span class="keyword">from</span> google.colab <span class="keyword">import</span> drive</span><br><span class="line"><span class="keyword">import</span> csv</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">from</span> openpyxl <span class="keyword">import</span> load_workbook</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"> </span><br><span class="line"><span class="comment">###google driveに接続する.ローカル実行の場合は消してください.</span></span><br><span class="line">drive.mount(<span class="string">'/content/drive'</span>)</span><br><span class="line">%cd <span class="string">'/content/drive/MyDrive/Colab_Notebooks/material_test'</span></span><br><span class="line"><span class="comment">###</span></span><br><span class="line"></span><br><span class="line">filenames = glob(<span class="string">'*.csv'</span>)</span><br><span class="line"><span class="built_in">print</span>(filenames)</span><br><span class="line"> </span><br><span class="line"><span class="comment">#for filename in filenames:</span></span><br><span class="line"><span class="keyword">with</span> <span class="built_in">open</span>(<span class="string">'材料試験_H300W_No.1_データリスト.csv'</span>,encoding=<span class="string">"utf8"</span>,errors=<span class="string">'ignore'</span>) <span class="keyword">as</span> f:</span><br><span class="line"> f_csv = csv.reader(f)</span><br><span class="line"> <span class="built_in">next</span>(f_csv)</span><br><span class="line"> data = <span class="built_in">list</span>(f_csv)</span><br><span class="line"> a = np.array(data)</span><br><span class="line"> load = a[<span class="number">1</span>:,<span class="number">2</span>]</span><br><span class="line"> a = a[<span class="number">1</span>:,:] <span class="comment">#文字列の次から</span></span><br><span class="line"> x = <span class="built_in">range</span>(np.shape(a)[<span class="number">0</span>])</span><br><span class="line"> y = <span class="built_in">len</span>(data) - <span class="number">1</span> <span class="comment">#行数を数える</span></span><br><span class="line"> case1 = np.empty([y,<span class="number">8</span>],dtype = <span class="built_in">float</span>)</span><br><span class="line"> </span><br><span class="line"><span class="comment">#########################</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> x:</span><br><span class="line"> case1[i,<span class="number">0</span>] = a[i,<span class="number">2</span>] <span class="comment">#load</span></span><br><span class="line"> case1[i,<span class="number">1</span>] = a[i,<span class="number">3</span>] <span class="comment">#disp</span></span><br><span class="line"> <span class="keyword">if</span> <span class="built_in">float</span>(a[<span class="built_in">int</span>(y/<span class="number">2</span>),<span class="number">4</span>]) > <span class="number">0</span> : <span class="comment">#縦ひずみを判定する</span></span><br><span class="line"> case1[i,<span class="number">2</span>] = a[i,<span class="number">4</span>] <span class="comment">#縦ひずみ1を定義する</span></span><br><span class="line"> <span class="keyword">if</span> <span class="built_in">float</span>(a[<span class="built_in">int</span>(y/<span class="number">2</span>),<span class="number">5</span>]) > <span class="number">0</span> : <span class="comment">#縦ひずみを判定する</span></span><br><span class="line"> case1[i,<span class="number">3</span>] = a[i,<span class="number">5</span>] <span class="comment">#縦ひずみ2を定義する</span></span><br><span class="line"> case1[i,<span class="number">4</span>] = a[i,<span class="number">6</span>] <span class="comment">#横ひずみ1を定義する</span></span><br><span class="line"> case1[i,<span class="number">5</span>] = a[i,<span class="number">7</span>] <span class="comment">#横ひずみ2を定義する</span></span><br><span class="line"> <span class="keyword">else</span> :</span><br><span class="line"> case1[i,<span class="number">4</span>] = a[i,<span class="number">5</span>] <span class="comment">#横ひずみ1を定義する</span></span><br><span class="line"> case1[i,<span class="number">5</span>] = a[i,<span class="number">7</span>] <span class="comment">#横ひずみ2を定義する</span></span><br><span class="line"> case1[i,<span class="number">3</span>] = a[i,<span class="number">6</span>] <span class="comment">#縦ひずみ2を定義する</span></span><br><span class="line"> <span class="keyword">if</span> i == y :</span><br><span class="line"> <span class="keyword">break</span></span><br><span class="line"> striantate = (case1[:,<span class="number">2</span>]+case1[:,<span class="number">3</span>])/<span class="number">2</span> <span class="comment">#縦ひずみ平均値</span></span><br><span class="line"> strianyoko = (case1[:,<span class="number">4</span>]+case1[:,<span class="number">5</span>])/<span class="number">2</span> <span class="comment">#横ひずみ平均値</span></span><br><span class="line"><span class="comment">############################</span></span><br><span class="line"><span class="comment"># エクセルシート(テンプレート)を読み込む</span></span><br><span class="line">wb = load_workbook(<span class="string">"template_mt.xlsx"</span>, data_only=<span class="literal">True</span>) <span class="comment">#エクセルシートを導入する</span></span><br><span class="line">wb1 = wb.active <span class="comment">#シートを選択する</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#################</span></span><br><span class="line"> </span><br><span class="line">A = wb1[<span class="string">'F9'</span>].value <span class="comment">#断面積を取得する</span></span><br><span class="line">case1[:,<span class="number">6</span>] = case1[:,<span class="number">0</span>] *<span class="number">1000</span>/ A <span class="comment">#応力の算出</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">#################</span></span><br></pre></td></tr></table></figure><h2 id="降伏点の算出方">1.2. 降伏点の算出方¶</h2><hr><p>標準材料試験に対して,ひずみが4000まで,基本降伏点を超えているため,降伏点の算出は:</p><blockquote><p>ひずみが4000までの最大応力とする.</p></blockquote><p>引張強度は応力の最大値を取得する.</p><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">sigma_y = <span class="number">0</span></span><br><span class="line">i = <span class="number">0</span></span><br><span class="line"><span class="keyword">while</span> striantate[i] < <span class="number">4000</span>:</span><br><span class="line"> sigma_y= <span class="built_in">max</span>(sigma_y,case1[i,<span class="number">6</span>])</span><br><span class="line"> i = i+<span class="number">1</span></span><br><span class="line">sigma_u = <span class="built_in">max</span>(case1[:,<span class="number">6</span>])</span><br><span class="line"><span class="built_in">print</span>(<span class="string">'降伏点:'</span>,sigma_y)</span><br><span class="line"><span class="built_in">print</span>(<span class="string">'引張強度:'</span>,sigma_u)</span><br></pre></td></tr></table></figure><h2 id="最小二乗法を用いたヤング率の求め">1.3. 最小二乗法を用いたヤング率の求め¶</h2><hr><ul><li>実験の初期ノイズおよび,降伏点付近の塑性化の影響を排除するため,ヤング率の算出範囲は \(0.2\sigma_y - 0.7\sigma_y\)となった.<br><br>最小二乗法を用いて,曲線の傾き\(k_1\)は以下のように算出された:</li></ul><div>$$k_1 = \frac{n \sum_{i=1}^{n} x_{i} y_{i}-\sum_{i=1}^{n} x_{i} \sum_{i=1}^{n} y_{i}}{n \sum_{i=1}^{n} x_{i}^{2}-\left(\sum_{i=1}^{n} x_{i}\right)^{2}}$$</div><br> コードで見やすいため,以下のように省略で表記する.$$k_1 = \frac {na1 - a21\times a22} {nb1 - a21^2}$$<p>なお,決定係数\(R^2\)については,残差の二乗和を標本値の平均値 \(\overline{y}\)からの偏差の二乗和で割ったものを1から引いた値であり,以下のような式で算出した.</p><div>$$R^{2} = 1-\frac{\sum_{i=1}^{N}\left(y_{i}-f_{i}\right)^{2}}{\sum_{j=1}^{N}\left(y_{j}-\bar{y}\right)^{2}}$$<br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">i = <span class="number">0</span>; a1 = <span class="number">0</span>; a21 = <span class="number">0</span>; a22 = <span class="number">0</span>; k1 = <span class="number">0</span>; b1 = <span class="number">0</span>; n=<span class="number">0</span>;pc = <span class="number">0</span></span><br><span class="line"><span class="keyword">for</span> j <span class="keyword">in</span> case1[:,<span class="number">6</span>]:</span><br><span class="line"> <span class="keyword">if</span> j > <span class="number">0.2</span>*sigma_y <span class="keyword">and</span> j < <span class="number">0.7</span>*sigma_y:</span><br><span class="line"> a1 += (striantate[i] * case1[i,<span class="number">6</span>])</span><br><span class="line"> a21 += striantate[i]</span><br><span class="line"> a22 += case1[i,<span class="number">6</span>]</span><br><span class="line"> b1 += striantate[i] ** <span class="number">2</span></span><br><span class="line"> pc += strianyoko[i]/striantate[i]</span><br><span class="line"> n += <span class="number">1</span></span><br><span class="line"> i = i+<span class="number">1</span></span><br><span class="line"></span><br><span class="line">k1 = (n*a1 - a21*a22)/(n*b1-a21**<span class="number">2</span>) <span class="comment">#yong's modulus</span></span><br><span class="line">b0 = a22/n - k1*a21/n <span class="comment">#intercept 切片</span></span><br><span class="line">pc = -pc/n <span class="comment">#Poisson coefficient ポアソン比</span></span><br><span class="line"><span class="comment">####### R決定係数の求め</span></span><br><span class="line">i = <span class="number">0</span>; ssr = <span class="number">0</span>; sst = <span class="number">0</span></span><br><span class="line">ymean = a22/n</span><br><span class="line"><span class="keyword">for</span> j <span class="keyword">in</span> case1[:,<span class="number">6</span>]:</span><br><span class="line"> <span class="keyword">if</span> j > <span class="number">0.2</span>*sigma_y <span class="keyword">and</span> j < <span class="number">0.7</span>*sigma_y:</span><br><span class="line"> ssr += (case1[i,<span class="number">6</span>] - (striantate[i]*k1+b0))**<span class="number">2</span></span><br><span class="line"> sst += (case1[i,<span class="number">6</span>] - ymean)**<span class="number">2</span></span><br><span class="line"> i += <span class="number">1</span></span><br><span class="line">R2 = <span class="number">1</span> - ssr/sst <span class="comment">#R2 Coefficient of determination,決定係数</span></span><br><span class="line"><span class="comment">######</span></span><br><span class="line"><span class="built_in">print</span>(<span class="string">'ヤング率E = '</span>,k1*<span class="number">10</span>**<span class="number">6</span>)</span><br><span class="line"><span class="built_in">print</span>(<span class="string">'ポアソン比 = '</span>,pc)</span><br><span class="line"><span class="built_in">print</span>(<span class="string">'決定係数R^2 = '</span>,R2)</span><br></pre></td></tr></table></figure><h2 id="グラフの出力">1.4. グラフの出力¶</h2><hr><p>matplotlibを用いてグラフの出力</p> <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">##############</span></span><br><span class="line"><span class="comment">#グラフを書く</span></span><br><span class="line">plt.plot(striantate,case1[:,<span class="number">6</span>], label=<span class="string">"stress-strain"</span>,color=<span class="string">'black'</span>,linewidth=<span class="number">0.75</span>)</span><br><span class="line">plt.xlabel(<span class="string">"Strain"</span>)</span><br><span class="line">plt.ylabel(<span class="string">"Stress [$N/mm^2$]"</span>)</span><br><span class="line">plt.ylim(<span class="number">0</span>, <span class="number">500</span>)</span><br><span class="line">plt.xlim(<span class="number">0</span>, <span class="number">70000</span>)</span><br><span class="line">plt.grid(color=<span class="string">"k"</span>, linestyle=<span class="string">":"</span>) <span class="comment"># メッシュ背景を点線に設定する</span></span><br><span class="line">plt.legend(loc=<span class="number">4</span>,numpoints=<span class="number">1</span>) <span class="comment">#凡例</span></span><br><span class="line">plt.savefig(<span class="string">'stress-strain.svg'</span>) <span class="comment">#svgとして保存</span></span><br><span class="line">plt.show()</span><br><span class="line"><span class="comment">###############</span></span><br><span class="line"><span class="comment">### データを書き込む</span></span><br><span class="line">最後に処理完了したデータを全部Excelテンプレートに書き込む.</span><br><span class="line">wb1.cell(<span class="number">6</span>,<span class="number">10</span>,sigma_y)</span><br><span class="line">wb1.cell(<span class="number">6</span>,<span class="number">11</span>,sigma_u)</span><br><span class="line">wb1.cell(<span class="number">6</span>,<span class="number">12</span>,k1)</span><br><span class="line">wb1.cell(<span class="number">6</span>,<span class="number">13</span>,pc)</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">3</span>,y) :</span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">2</span>,<span class="number">8</span>) :</span><br><span class="line"> wb1.cell(i,j,case1[i-<span class="number">3</span>,j-<span class="number">2</span>]) <span class="comment">#シートにi行j列にデータを書き込む</span></span><br><span class="line">wb.save(<span class="string">"111.xlsx"</span>) <span class="comment">#保存する</span></span><br></pre></td></tr></table></figure><h1 id="Full-Code">2. Full Code¶</h1><ol><li>フォルダ内に<code>.csv</code>ファイルを探して,名前を取得する.</li><li>生データを読み取り,データ処理を行う.</li><li>生データから,縦ひずみ,横ひずみ平均値と応力を算出する.</li><li>降伏点および引張強度を算出する.</li><li>最小二乗法を用いてヤング率およびポアソン比の算出.</li><li>応力-ひずみ関係グラフを書く,出力,保存する.</li><li>計算結果および生データをテンプレートに保存する.</li></ol><figure class="highlight python"><figcaption><span>material-test.py >folded</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> glob <span class="keyword">import</span> glob</span><br><span class="line"><span class="keyword">from</span> google.colab <span class="keyword">import</span> drive</span><br><span class="line"><span class="keyword">import</span> csv</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">from</span> openpyxl <span class="keyword">import</span> load_workbook</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"> </span><br><span class="line"><span class="comment">###</span></span><br><span class="line">drive.mount(<span class="string">'/content/drive'</span>)</span><br><span class="line">%cd <span class="string">'/content/drive/MyDrive/Colab_Notebooks/material_test'</span></span><br><span class="line">filenames = glob(<span class="string">'*.csv'</span>)</span><br><span class="line"><span class="comment">###</span></span><br><span class="line">m=<span class="number">1</span>; <span class="comment">#生データ書き込むためcellの列数,</span></span><br><span class="line">row1 = <span class="number">6</span> <span class="comment">#計算結果を書き込むための行数</span></span><br><span class="line"><span class="comment">############################</span></span><br><span class="line"><span class="comment"># エクセルシート(テンプレート)を読み込む</span></span><br><span class="line">wb = load_workbook(<span class="string">"template_mt.xlsx"</span>, data_only=<span class="literal">True</span>) <span class="comment">#エクセルシートを導入する</span></span><br><span class="line">wb1 = wb.active <span class="comment">#シートを選択する</span></span><br><span class="line"></span><br><span class="line"><span class="comment">######</span></span><br><span class="line"><span class="keyword">for</span> filename <span class="keyword">in</span> filenames:</span><br><span class="line"> fname = filename.split(<span class="string">'_'</span>)[-<span class="number">2</span>]</span><br><span class="line"> <span class="keyword">with</span> <span class="built_in">open</span>(filename,encoding=<span class="string">"utf8"</span>,errors=<span class="string">'ignore'</span>) <span class="keyword">as</span> f:</span><br><span class="line"> f_csv = csv.reader(f)</span><br><span class="line"> <span class="built_in">next</span>(f_csv)</span><br><span class="line"> data = <span class="built_in">list</span>(f_csv)</span><br><span class="line"> a = np.array(data)</span><br><span class="line"> load = a[<span class="number">1</span>:,<span class="number">2</span>]</span><br><span class="line"> a = a[<span class="number">1</span>:,:] <span class="comment">#文字列の次から</span></span><br><span class="line"> x = <span class="built_in">range</span>(np.shape(a)[<span class="number">0</span>])</span><br><span class="line"> y = <span class="built_in">len</span>(data) - <span class="number">1</span> <span class="comment">#行数を数える</span></span><br><span class="line"> case1 = np.empty([y,<span class="number">8</span>],dtype = <span class="built_in">float</span>)</span><br><span class="line"> </span><br><span class="line"> <span class="comment">#########################</span></span><br><span class="line"> <span class="keyword">for</span> i <span class="keyword">in</span> x:</span><br><span class="line"> case1[i,<span class="number">0</span>] = a[i,<span class="number">2</span>] <span class="comment">#load</span></span><br><span class="line"> case1[i,<span class="number">1</span>] = a[i,<span class="number">3</span>] <span class="comment">#disp</span></span><br><span class="line"> <span class="keyword">if</span> <span class="built_in">float</span>(a[<span class="built_in">int</span>(y/<span class="number">2</span>),<span class="number">4</span>]) > <span class="number">0</span> : <span class="comment">#縦ひずみを判定する</span></span><br><span class="line"> case1[i,<span class="number">2</span>] = a[i,<span class="number">4</span>] <span class="comment">#縦ひずみ1を定義する</span></span><br><span class="line"> <span class="keyword">if</span> <span class="built_in">float</span>(a[<span class="built_in">int</span>(y/<span class="number">2</span>),<span class="number">5</span>]) > <span class="number">0</span> : <span class="comment">#縦ひずみを判定する</span></span><br><span class="line"> case1[i,<span class="number">3</span>] = a[i,<span class="number">5</span>] <span class="comment">#縦ひずみ2を定義する</span></span><br><span class="line"> case1[i,<span class="number">4</span>] = a[i,<span class="number">6</span>] <span class="comment">#横ひずみ1を定義する</span></span><br><span class="line"> case1[i,<span class="number">5</span>] = a[i,<span class="number">7</span>] <span class="comment">#横ひずみ2を定義する</span></span><br><span class="line"> <span class="keyword">else</span> :</span><br><span class="line"> case1[i,<span class="number">4</span>] = a[i,<span class="number">5</span>] <span class="comment">#横ひずみ1を定義する</span></span><br><span class="line"> case1[i,<span class="number">5</span>] = a[i,<span class="number">7</span>] <span class="comment">#横ひずみ2を定義する</span></span><br><span class="line"> case1[i,<span class="number">3</span>] = a[i,<span class="number">6</span>] <span class="comment">#縦ひずみ2を定義する</span></span><br><span class="line"> <span class="keyword">if</span> i == y :</span><br><span class="line"> <span class="keyword">break</span></span><br><span class="line"> striantate = (case1[:,<span class="number">2</span>]+case1[:,<span class="number">3</span>])/<span class="number">2</span> <span class="comment">#縦ひずみ平均値</span></span><br><span class="line"> strianyoko = (case1[:,<span class="number">4</span>]+case1[:,<span class="number">5</span>])/<span class="number">2</span> <span class="comment">#横ひずみ平均値</span></span><br><span class="line"></span><br><span class="line"> <span class="comment">#################</span></span><br><span class="line"> </span><br><span class="line"> A = wb1.cell(row1,<span class="number">6</span>).value <span class="comment">#断面積を取得する</span></span><br><span class="line"> case1[:,<span class="number">6</span>] = case1[:,<span class="number">0</span>] *<span class="number">1000</span>/ A <span class="comment">#応力の算出</span></span><br><span class="line"> </span><br><span class="line"> <span class="comment">#################降伏点および引張強度の算出</span></span><br><span class="line"> sigma_y = <span class="number">0</span></span><br><span class="line"> i = <span class="number">0</span></span><br><span class="line"> <span class="keyword">while</span> striantate[i] < <span class="number">4000</span>:</span><br><span class="line"> sigma_y= <span class="built_in">max</span>(sigma_y,case1[i,<span class="number">6</span>])</span><br><span class="line"> i = i+<span class="number">1</span></span><br><span class="line"> sigma_u = <span class="built_in">max</span>(case1[:,<span class="number">6</span>])</span><br><span class="line"> <span class="comment">##############ヤング率の算出</span></span><br><span class="line"> i = <span class="number">0</span>; a1 = <span class="number">0</span>; a21 = <span class="number">0</span>; a22 = <span class="number">0</span>; k1 = <span class="number">0</span>; b1 = <span class="number">0</span>; n=<span class="number">0</span>;pc = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> case1[:,<span class="number">6</span>]:</span><br><span class="line"> <span class="keyword">if</span> j > <span class="number">0.2</span>*sigma_y <span class="keyword">and</span> j < <span class="number">0.7</span>*sigma_y:</span><br><span class="line"> a1 += (striantate[i] * case1[i,<span class="number">6</span>])</span><br><span class="line"> a21 += striantate[i]</span><br><span class="line"> a22 += case1[i,<span class="number">6</span>]</span><br><span class="line"> b1 += striantate[i] ** <span class="number">2</span></span><br><span class="line"> pc += strianyoko[i]/striantate[i]</span><br><span class="line"> n += <span class="number">1</span></span><br><span class="line"> i = i+<span class="number">1</span></span><br><span class="line"></span><br><span class="line"> k1 = (n*a1 - a21*a22)/(n*b1-a21**<span class="number">2</span>) <span class="comment">#yong's modulus</span></span><br><span class="line"> b0 = a22/n - k1*a21/n <span class="comment">#intercept 切片</span></span><br><span class="line"> pc = -pc/n <span class="comment">#Poisson coefficient ポアソン比</span></span><br><span class="line"> <span class="comment">####### R決定係数の求め</span></span><br><span class="line"> i = <span class="number">0</span>; ssr = <span class="number">0</span>; sst = <span class="number">0</span></span><br><span class="line"> ymean = a22/n</span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> case1[:,<span class="number">6</span>]:</span><br><span class="line"> <span class="keyword">if</span> j > <span class="number">0.2</span>*sigma_y <span class="keyword">and</span> j < <span class="number">0.7</span>*sigma_y:</span><br><span class="line"> ssr += (case1[i,<span class="number">6</span>] - (striantate[i]*k1+b0))**<span class="number">2</span></span><br><span class="line"> sst += (case1[i,<span class="number">6</span>] - ymean)**<span class="number">2</span></span><br><span class="line"> i += <span class="number">1</span></span><br><span class="line"> R2 = <span class="number">1</span> - ssr/sst <span class="comment">#R2 Coefficient of determination,決定係数</span></span><br><span class="line"> <span class="comment">##########グラフを書く</span></span><br><span class="line"> plt.plot(striantate,case1[:,<span class="number">6</span>], label=<span class="string">"stress-strain"</span>,color=<span class="string">'black'</span>,linewidth=<span class="number">0.75</span>)</span><br><span class="line"> plt.xlabel(<span class="string">"Strain"</span>)</span><br><span class="line"> plt.ylabel(<span class="string">"Stress [$N/mm^2$]"</span>)</span><br><span class="line"> plt.ylim(<span class="number">0</span>, <span class="number">500</span>)</span><br><span class="line"> plt.xlim(<span class="number">0</span>, <span class="number">70000</span>)</span><br><span class="line"> plt.grid(color=<span class="string">"k"</span>, linestyle=<span class="string">":"</span>) <span class="comment"># メッシュ背景を点線に設定する</span></span><br><span class="line"> plt.legend(loc=<span class="number">4</span>,numpoints=<span class="number">1</span>) <span class="comment">#凡例</span></span><br><span class="line"> plt.savefig(fname+<span class="string">'-stress-strain.svg'</span>) <span class="comment">#svgとして保存</span></span><br><span class="line"> plt.show()</span><br><span class="line"> <span class="comment">###############データの書き込む</span></span><br><span class="line"> wb1.cell(row1,<span class="number">10</span>,sigma_y)</span><br><span class="line"> wb1.cell(row1,<span class="number">11</span>,sigma_u)</span><br><span class="line"> wb1.cell(row1,<span class="number">12</span>,k1)</span><br><span class="line"> wb1.cell(row1,<span class="number">13</span>,pc)</span><br><span class="line"></span><br><span class="line"> <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">15</span>,y) :</span><br><span class="line"> j1 = <span class="number">0</span></span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(m,m+<span class="number">6</span>) :</span><br><span class="line"> wb1.cell(i,j,case1[i-<span class="number">15</span>,j1]) <span class="comment">#シートにi行j列にデータを書き込む</span></span><br><span class="line"> j1 +=<span class="number">1</span></span><br><span class="line"> </span><br><span class="line"> m += <span class="number">6</span></span><br><span class="line"> row1 += <span class="number">1</span></span><br><span class="line"></span><br><span class="line"> wb.save(<span class="string">"test.xlsx"</span>) <span class="comment">#保存する</span></span><br></pre></td></tr></table></figure><h2 id="Matlab-ver">2.1. Matlab ver.¶</h2><hr><blockquote><p>Matlabのバージョンも作っています.考え方は基本一緒.</p></blockquote><figure class="highlight matlab"><figcaption><span>material-test.m >folded</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">%%</span></span><br><span class="line">clc <span class="comment">%コマンドウインドウをクリアする</span></span><br><span class="line">clear <span class="comment">%ワークスペースのクリア</span></span><br><span class="line">file = dir(fullfile(<span class="string">'*.csv'</span>)); <span class="comment">%csvファイルの情報を全部読み込む</span></span><br><span class="line">filenames = {file.name}; <span class="comment">%csvファイル名を取得</span></span><br><span class="line">[~,n] = <span class="built_in">size</span>(filenames); <span class="comment">%csvファイルの個数を数える</span></span><br><span class="line">A = readmatrix(<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'F6:F8'</span>); <span class="comment">%断面積を取得する</span></span><br><span class="line"></span><br><span class="line"><span class="comment">%変数の定義</span></span><br><span class="line">stressmax = <span class="number">0</span>; avx = <span class="number">0</span>; avy = <span class="number">0</span>; avx2 = <span class="number">0</span>;</span><br><span class="line">Sxy = <span class="number">0</span>; Sx2 = <span class="number">0</span>; M = <span class="number">0</span>; Sxy1 = <span class="number">0</span>; Sxy2 = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">%%</span></span><br><span class="line"><span class="comment">%全てのデータを行列変換</span></span><br><span class="line"><span class="comment">%%%%figure</span></span><br><span class="line"> figure1 =<span class="built_in">figure</span>;</span><br><span class="line"> axes1 = axes(<span class="string">'Parent'</span>,figure1);</span><br><span class="line"><span class="built_in">hold</span>(axes1,<span class="string">'on'</span>);</span><br><span class="line">ylabel({<span class="string">'Stress [N/mm^2]'</span>});</span><br><span class="line">xlabel({<span class="string">'Strain'</span>});</span><br><span class="line"><span class="comment">%%%%%%%</span></span><br><span class="line"><span class="keyword">for</span> <span class="built_in">i</span> = <span class="number">1</span> : n</span><br><span class="line"> stress_y(<span class="built_in">i</span>) = <span class="number">0</span>;</span><br><span class="line"> k = strcat(filenames(<span class="built_in">i</span>)); <span class="comment">%文字列に変換する</span></span><br><span class="line"> data{<span class="built_in">i</span>,<span class="number">1</span>} = k{<span class="number">1</span>,<span class="number">1</span>}; <span class="comment">%名前を付けて</span></span><br><span class="line"> data{<span class="built_in">i</span>,<span class="number">2</span>} = readmatrix(k{<span class="number">1</span>,<span class="number">1</span>}); <span class="comment">%データを入れる</span></span><br><span class="line"> f = data{<span class="built_in">i</span>,<span class="number">2</span>}; <span class="comment">%data中のi行2列のデータを取り出す</span></span><br><span class="line"> f = f(:,<span class="number">3</span>:<span class="number">8</span>); <span class="comment">%計測データの3~8列(荷重,変位,ひずみ*4)を取り出す</span></span><br><span class="line"> data{<span class="built_in">i</span>,<span class="number">2</span>} = f;</span><br><span class="line"> [<span class="built_in">j</span>,~]=<span class="built_in">size</span>(data{<span class="built_in">i</span>,<span class="number">2</span>}); <span class="comment">%データ数の列数を数える</span></span><br><span class="line"> <span class="keyword">if</span> data{<span class="built_in">i</span>,<span class="number">2</span>}(<span class="built_in">j</span>/<span class="number">2</span>,<span class="number">4</span>)><span class="number">0</span> <span class="comment">%縦ひずみ2を判定する</span></span><br><span class="line"> next;</span><br><span class="line"> <span class="keyword">else</span> </span><br><span class="line"> data{<span class="built_in">i</span>,<span class="number">2</span>}(:,[<span class="number">4</span>,<span class="number">5</span>]) =data{<span class="built_in">i</span>,<span class="number">2</span>}(:,[<span class="number">5</span>,<span class="number">4</span>]); <span class="comment">%横ひずみと縦ひずみを並び替える</span></span><br><span class="line"> <span class="keyword">end</span></span><br><span class="line"> </span><br><span class="line"> <span class="comment">%応力・平均ひずみの出力</span></span><br><span class="line"> <span class="keyword">for</span> m=<span class="number">1</span>:<span class="built_in">j</span></span><br><span class="line"> stress(m) = data{<span class="built_in">i</span>,<span class="number">2</span>}(m,<span class="number">1</span>)/A(<span class="built_in">i</span>)*<span class="number">1000</span>; <span class="comment">%`応力の出力</span></span><br><span class="line"> strain(m,<span class="number">1</span>) = <span class="number">0.5</span>*(data{<span class="built_in">i</span>,<span class="number">2</span>}(m,<span class="number">3</span>) + data{<span class="built_in">i</span>,<span class="number">2</span>}(m,<span class="number">4</span>));</span><br><span class="line"> strain(m,<span class="number">2</span>) = <span class="number">-0.5</span>*(data{<span class="built_in">i</span>,<span class="number">2</span>}(m,<span class="number">5</span>) + data{<span class="built_in">i</span>,<span class="number">2</span>}(m,<span class="number">6</span>));</span><br><span class="line"> <span class="keyword">if</span> strain(m,<span class="number">1</span>) < <span class="number">4000</span></span><br><span class="line"> stress_y(<span class="built_in">i</span>)=<span class="built_in">max</span>(stress(m),stress_y(<span class="built_in">i</span>));</span><br><span class="line"> <span class="keyword">end</span></span><br><span class="line"> <span class="keyword">end</span></span><br><span class="line"> stressmax(<span class="built_in">i</span>) = <span class="built_in">max</span>(stress); <span class="comment">%応力最大値を取得する</span></span><br><span class="line"></span><br><span class="line"> <span class="comment">%平均値を取得する</span></span><br><span class="line"> <span class="keyword">for</span> m=<span class="number">1</span>:<span class="built_in">j</span></span><br><span class="line"> <span class="keyword">if</span> (stress(m) > (<span class="number">0.1</span>*stress_y(<span class="built_in">i</span>))) && (stress(m) < (<span class="number">0.7</span>*stress_y(<span class="built_in">i</span>)))</span><br><span class="line"> avx = avx + strain(m,<span class="number">1</span>);</span><br><span class="line"> avy = avy + stress(m);</span><br><span class="line"> avx2 = avx2 + strain(m,<span class="number">2</span>);</span><br><span class="line"> M = M+<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">end</span></span><br><span class="line"> <span class="keyword">end</span> </span><br><span class="line"> avx = avx/M ; avy = avy/M; avx2 = avx2/M;</span><br><span class="line"> <span class="comment">%最小二乗法</span></span><br><span class="line"> <span class="keyword">for</span> m=<span class="number">1</span>:<span class="built_in">j</span></span><br><span class="line"> <span class="keyword">if</span> (stress(m) > (<span class="number">0.1</span>*stress_y(<span class="built_in">i</span>))) && (stress(m) < (<span class="number">1.7</span>*stress_y(<span class="built_in">i</span>)))</span><br><span class="line"> Sxy = Sxy+(strain(m,<span class="number">1</span>)-avx)*(stress(m)-avy);</span><br><span class="line"> Sx2 = Sx2+(strain(m,<span class="number">1</span>)-avx)^<span class="number">2</span>;</span><br><span class="line"> Sxy1 = Sxy1+(strain(m,<span class="number">2</span>)-avx2)*(strain(m,<span class="number">1</span>)-avx);</span><br><span class="line"> Sxy2 = Sxy2+(strain(m,<span class="number">2</span>)-avx2)^<span class="number">2</span>;</span><br><span class="line"> <span class="keyword">end</span></span><br><span class="line"> <span class="keyword">end</span> </span><br><span class="line"> Yongs(<span class="built_in">i</span>) = Sxy/Sx2*<span class="number">10</span>^<span class="number">6</span>;</span><br><span class="line"> b = avy - Yongs * avx;</span><br><span class="line"> Poissons(<span class="built_in">i</span>) = Sxy2/Sxy1;</span><br><span class="line"> </span><br><span class="line"> <span class="built_in">plot</span>(strain(:,<span class="number">1</span>),stress); <span class="comment">%図の追加</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line">writematrix(data{<span class="number">1</span>,<span class="number">2</span>},<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'A15'</span>)</span><br><span class="line">writematrix(data{<span class="number">2</span>,<span class="number">2</span>},<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'G15'</span>)</span><br><span class="line">writematrix(data{<span class="number">3</span>,<span class="number">2</span>},<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'M15'</span>)</span><br><span class="line">writematrix(stress_y',<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'J6'</span>)</span><br><span class="line">writematrix(stressmax',<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'K6'</span>)</span><br><span class="line">writematrix(Yongs',<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'L6'</span>)</span><br><span class="line">writematrix(Poissons',<span class="string">'template_mt.xlsx'</span>,<span class="string">'sheet'</span>,<span class="number">1</span>,<span class="string">'range'</span>,<span class="string">'M6'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">%%%Figure</span></span><br><span class="line">xlim(axes1,[<span class="number">0</span> <span class="number">70000</span>]);</span><br><span class="line">ylim(axes1,[<span class="number">0</span> <span class="number">500</span>]);</span><br><span class="line">box(axes1,<span class="string">'on'</span>);</span><br><span class="line"><span class="built_in">hold</span>(axes1,<span class="string">'off'</span>);</span><br><span class="line">legend1 = <span class="built_in">legend</span>(axes1,<span class="string">'show'</span>);</span><br><span class="line"><span class="built_in">legend</span>(<span class="string">'No.1'</span>,<span class="string">'No.2'</span>,<span class="string">'No.3'</span>,<span class="string">'location'</span>,<span class="string">'southeast'</span>);</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>]]></content>
<summary type="html"><h1 id="材料試験自動データ処理">1. 材料試験自動データ処理¶</h1>
<hr>
<p><a href="/lang/material-test/">中文</a></p>
<p>鋼材の材料試験の自動化データ処理スクリプト.<br><br>
実現できる機能は 降伏点,引張強度の算出.ヤング率,ポアソン比の算出.最後に,自動でグラフを出力,レポートとしてExcelに保存する.</p>
<div class="img-x">
<img height=" 20 " width=" 20 " src=" https://cdn.jsdelivr.net/npm/simple-icons@v5/icons/googlecolab.svg "> <img height=" 20 " width=" 20 " src=" https://cdn.jsdelivr.net/npm/simple-icons@v5/icons/jupyter.svg "></div>
<blockquote>
<p><i class="fab fa-google-drive"></i> Google colab ソースコード<a href="https://colab.research.google.com/drive/1ED1jSNf7LIF0wjTKKv-pL2neszNev9Gs?usp=sharing">source_code</a></p>
</blockquote></summary>
<category term="Python" scheme="https://www.chenyu-k.com/categories/Python/"/>
<category term="Python" scheme="https://www.chenyu-k.com/tags/Python/"/>
<category term="Matlab" scheme="https://www.chenyu-k.com/tags/Matlab/"/>
<category term="Data_processing" scheme="https://www.chenyu-k.com/tags/Data-processing/"/>
</entry>
<entry>
<title>Latex编译下插入png,jpg</title>
<link href="https://www.chenyu-k.com/2021/08/12/2021-08-12-Latex-pic/"/>
<id>https://www.chenyu-k.com/2021/08/12/2021-08-12-Latex-pic/</id>
<published>2021-08-12T10:05:06.000Z</published>
<updated>2021-08-24T09:56:55.000Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="LaTeX-插入png-jpg的设定">1. \(\LaTeX\)插入png,jpg的设定¶</h1><p>首先LaTeX本身并不支持插图的功能,插图需要导入<code>graphicx</code>宏包来完成。</p><p>在LaTeX用中文或者日语写论文时,编译环境使用Latex较为常见。latex编译模式下如果直接插入png或者jpg的图会告诉你,编译错误没有设置<code>boundbox</code>。</p><p>这个时候就需要使用latex+dvipdfmx编译,调用<code>graphicx</code>时需要指定dvipdfmx.</p><blockquote><p>\(\LaTeX\)插入图片最好的格式是EPS</p></blockquote><p><strong>EPS可以直接插入,而且作为高质量的矢量图片,笔者认为这是论文出图的首选。</strong></p><h2 id="more">1.1. ¶</h2><h2 id="设置方法">1.2. 设置方法¶</h2><p>latex直接插入jpg or png,需要设置<code>boundbox</code>,调整bb相当麻烦,两个办法,</p><ul><li><p>jpg or png 转换为eps格式(并不推荐)</p></li><li><p>通过读取<code>dvipdfmx</code>包来自动获取bb信息然后放入文字中。</p></li></ul><p>例如:<br>(笔者喜欢在全局里导入dvipdfmx的条件,当然在调用graphics宏包时导入也可以)</p><figure class="highlight tex"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">\documentclass</span>[a4paper,dvipdfmx]{jsreport}</span><br></pre></td></tr></table></figure><p>然后还需要加上<code>bmpsize</code>包来主动获取图片的bb信息,以适配文章格式</p><figure class="highlight tex"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">\usepackage</span>{bmpsize}</span><br></pre></td></tr></table></figure><blockquote><p>注意 <code>color</code> 和 <code>graphics</code> 包同时使用时,必须在<code>documentclass</code>上面添加<code>dvipdfms</code>否则会出现定义不明确的错误,因为<code>color</code>和<code>graphics</code>都是默认div。</p></blockquote><h2 id="对于pdflatex编译模式下">1.3. 对于pdflatex编译模式下¶</h2><p>pdflatex编译下可以自由导入pdf,jpg,png但是无法导入eps矢量图。这个时候就需要调入<code>epstopdf</code>宏包来支持eps的导入</p><figure class="highlight tex"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">\usepackage</span>{epstopdf}</span><br></pre></td></tr></table></figure><h2 id="各种编译方式的图片格式">1.4. 各种编译方式的图片格式¶</h2><p>开头也说过,latex本身是不支持导入图片的,导入图片的</p><table><thead><tr><th>格式</th><th>矢量图</th><th>位图</th></tr></thead><tbody><tr><td>latex</td><td>.eps</td><td>n/a</td></tr><tr><td>latex + dvipdfmx</td><td>.eps .pdf</td><td>.jpg .png .bmp</td></tr><tr><td>pdflatex</td><td>.pdf</td><td>.jpg .png</td></tr><tr><td>pdflatex 调用epstopdf</td><td>.eps .pdf</td><td>.jpg .png</td></tr><tr><td>xelatex</td><td>.eps .pdf</td><td>.jpg .png .bmp</td></tr></tbody></table><h2 id="导入图片">1.5. 导入图片¶</h2><p>在调用好宏包之后,就可以正常导入png位图了。<br>在论文中我一般喜欢用以下方式导入</p><figure class="highlight tex"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">\begin</span>{figure}[htbp]</span><br><span class="line"> <span class="keyword">\centering</span></span><br><span class="line"> <span class="keyword">\includegraphics</span>[width=<span class="keyword">\textwidth</span>]{picture/name.png}</span><br><span class="line"> <span class="keyword">\caption</span>{caption}</span><br><span class="line"> <span class="keyword">\label</span>{label}</span><br><span class="line"> <span class="keyword">\end</span>{figure}</span><br></pre></td></tr></table></figure><h2 id="Reference">1.6. Reference¶</h2><hr><ul><li><p><a href="https://texwiki.texjp.org/?dvipdfmx%2F%E7%94%BB%E5%83%8F%E3%81%AE%E3%81%A8%E3%82%8A%E3%81%93%E3%81%BF">dvipdfmx的使用方法</a></p></li><li><p><a href="https://www.notion.so/Latex-efc7176ff4954cbcaff15bf4c97d7004">Latex插入多栏图片</a></p></li><li><p>Latex_thumbnail来自Jonas Jacek <span class="url"><a rel="nofollow" class="external text" href="https://jonas.me/">jonas.me</a></span>,<a href="https://creativecommons.org/licenses/by/4.0" title="Creative Commons Attribution 4.0">CC BY 4.0</a>,<a href="https://commons.wikimedia.org/w/index.php?curid=89012582"></a></p></li></ul>]]></content>
<summary type="html"><h1 id="LaTeX-插入png-jpg的设定">1. \(\LaTeX\)插入png,jpg的设定¶</h1>
<p>首先LaTeX本身并不支持插图的功能,插图需要导入<code>graphicx</code>宏包来完成。</p>
<p>在LaTeX用中文或者日语写论文时,编译环境使用Latex较为常见。latex编译模式下如果直接插入png或者jpg的图会告诉你,编译错误没有设置<code>boundbox</code>。</p>
<p>这个时候就需要使用latex+dvipdfmx编译,调用<code>graphicx</code>时需要指定dvipdfmx.</p>
<blockquote>
<p>\(\LaTeX\)插入图片最好的格式是EPS</p>
</blockquote>
<p><strong>EPS可以直接插入,而且作为高质量的矢量图片,笔者认为这是论文出图的首选。</strong></p>
<h2 id="more">1.1. </h2></summary>
<category term="Latex" scheme="https://www.chenyu-k.com/categories/Latex/"/>
<category term="Latex" scheme="https://www.chenyu-k.com/tags/Latex/"/>
</entry>
<entry>
<title>How to select Abaqus Solid Element Type</title>
<link href="https://www.chenyu-k.com/2021/08/05/2021-08-05-Abaqus-element-type/"/>
<id>https://www.chenyu-k.com/2021/08/05/2021-08-05-Abaqus-element-type/</id>
<published>2021-08-05T04:47:31.000Z</published>
<updated>2021-08-05T05:53:11.000Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="Abaqus要素タイプの選択-br-如何选择Abaqus的实体单元类型">1. Abaqus要素タイプの選択 如何选择Abaqus的实体单元类型¶</h1><p>| | First-order reduced-integration elements|</p>]]></content>
<summary type="html"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="Abaqus要素タイプの選択-br-如何选择Abaqus的实体单元</summary>
<category term="Abaqus" scheme="https://www.chenyu-k.com/categories/Abaqus/"/>
<category term="Abaqus" scheme="https://www.chenyu-k.com/tags/Abaqus/"/>
</entry>
<entry>
<title>How to use right-click to open CMD</title>
<link href="https://www.chenyu-k.com/2021/08/04/right-click/"/>
<id>https://www.chenyu-k.com/2021/08/04/right-click/</id>
<published>2021-08-04T12:53:33.000Z</published>
<updated>2021-09-06T05:26:56.000Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="右クリックでCMDを素早く起動する方法-br-如何通过右键快速启动CMD">1. 右クリックでCMDを素早く起動する方法如何通过右键快速启动CMD¶</h1><p><img src="https://img.icons8.com/ios-glyphs/30/000000/cmd.png" alt><br>Most of time, when we want op the cmd. we should open CMD frst, and then copy the path ,use <code>cd 'path'</code> to start command.</p><p>Now,you can open CMD from the current path by modifying the registry.</p><span id="more"></span><p>Creat a ‘xx.reg’, copy the following code into it,and then run it.</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">Windows Registry Editor Version 5.00</span><br><span class="line"></span><br><span class="line">[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere]</span><br><span class="line">@=<span class="string">"open cmd"</span></span><br><span class="line"><span class="string">"Icon"</span>=<span class="string">"cmd.exe"</span></span><br><span class="line">[HKEY_CLASSES_ROOT\Directory\shell\OpeCmdHere\<span class="built_in">command</span>]</span><br><span class="line">@=<span class="string">"cmd.exe /s /k pushd \"%V\""</span></span><br><span class="line">[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]</span><br><span class="line">@=<span class="string">"open cmd"</span></span><br><span class="line"><span class="string">"Icon"</span>=<span class="string">"cmd.exe"</span></span><br><span class="line">[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\<span class="built_in">command</span>]</span><br><span class="line">@=<span class="string">"cmd.exe /s /k pushd \"%V\""</span></span><br><span class="line">[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere]</span><br><span class="line">@=<span class="string">"open cmd"</span></span><br><span class="line"><span class="string">"Icon"</span>=<span class="string">"cmd.exe"</span></span><br><span class="line">[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere\<span class="built_in">command</span>]</span><br><span class="line">@=<span class="string">"cmd.exe /s /k pushd \"%V\""</span></span><br><span class="line">[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere]</span><br><span class="line">@=<span class="string">"open cmd"</span></span><br><span class="line"><span class="string">"Icon"</span>=<span class="string">"cmd.exe"</span></span><br><span class="line">[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere\<span class="built_in">command</span>]</span><br><span class="line">@=<span class="string">"cmd.exe /s /k pushd \"%V\""</span></span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><h1 id="右クリックでCMDを素早く起動する方法-br-如何通过右键快速启动CMD">1. 右クリックでCMDを素早く起動する方法如何通过右键快速启动CMD¶</h1>
<p><img src="https://img.icons8.com/ios-glyphs/30/000000/cmd.png" alt><br>
Most of time, when we want op the cmd. we should open CMD frst, and then copy the path ,use <code>cd 'path'</code> to start command.</p>
<p>Now,you can open CMD from the current path by modifying the registry.</p></summary>
<category term="computer science" scheme="https://www.chenyu-k.com/categories/computer-science/"/>
<category term="Tips" scheme="https://www.chenyu-k.com/tags/Tips/"/>
</entry>
<entry>
<title>Hello World</title>
<link href="https://www.chenyu-k.com/2021/07/31/hello-world/"/>
<id>https://www.chenyu-k.com/2021/07/31/hello-world/</id>
<published>2021-07-31T14:51:36.224Z</published>
<updated>2021-08-12T12:41:08.310Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h2 id="preface">0.1. preface¶</h2><p>This blog will record some of the difficulties and solutions I encountered during my studies, and I will also summarize some basic knowledge related to my profession.</p><h2 id="Acknowledgements">0.2. Acknowledgements¶</h2><p>The website framework uses <a href="https://hexo.io/">Hexo</a>, and the theme is used from <a href="https://github.com/ppoffice/hexo-theme-icarus">Icarus</a> and <a href="https://github.com/removeif/hexo-theme-amazing">removeif</a>.</p>]]></content>
<summary type="html"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h2 id="preface">0.1. preface¶</h2>
<p>Th</summary>
</entry>
<entry>
<title>Preface</title>
<link href="https://www.chenyu-k.com/2021/07/30/Preface/"/>
<id>https://www.chenyu-k.com/2021/07/30/Preface/</id>
<published>2021-07-30T06:30:16.000Z</published>
<updated>2021-08-01T06:23:31.444Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="Preface">1. Preface¶</h1><blockquote><p>zzzzz</p></blockquote><p>ummmmmmm</p>]]></content>
<summary type="html"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="Preface">1. Preface¶</h1>
<blockq</summary>
<category term="Other" scheme="https://www.chenyu-k.com/categories/Other/"/>
</entry>
<entry>
<title>Abaqus job monitor</title>
<link href="https://www.chenyu-k.com/2021/07/30/abaqusstop/"/>
<id>https://www.chenyu-k.com/2021/07/30/abaqusstop/</id>
<published>2021-07-30T06:30:16.000Z</published>
<updated>2021-08-04T15:05:34.091Z</updated>
<content type="html"><![CDATA[<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><p><img src="https://img.shields.io/badge/Abaqus-V.2020-blue?logo=Dassault%20Syst%C3%A8mes" alt="abaqus"></p><h1 id="运用python对abaqus进行监控">1. 运用python对abaqus进行监控¶</h1><p>在通过abaqus进行计算时,很多时候通过监视器或者查看.sta文件是太清楚解析算到哪一步的。<br><strong>运用python对abaqus CAE内置的监视器进行监控管理,特别对于非线性的分析能可以最大限度计算得到自己想要的数据,减少计算成本。</strong></p><span id="more"></span><h2 id="监控原理">1.1. 监控原理¶</h2><p>利用abaqus CAE里的监视器,对模型指定的集合进行监视,分析过程中如果长变量达到某个指定的值就中止分析或者跳过这个分析步之类的指令。<br>这个命令可以用过monitorManager对象中写回调函数(callback function)来完成。</p><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">printMessages</span>(<span class="params">jobname,messagetype,data,userdata</span>):</span></span><br><span class="line"> <span class="built_in">print</span> <span class="string">'job name:%s, messagetype:%s'</span>%(jobname, messagetype)</span><br><span class="line"> <span class="built_in">print</span> <span class="string">'data members:'</span></span><br><span class="line"> <span class="built_in">format</span> = <span class="string">'%-18s %s'</span></span><br><span class="line"> <span class="built_in">print</span> <span class="built_in">format</span>%(<span class="string">'member'</span>,<span class="string">'value'</span>)</span><br><span class="line"> members = <span class="built_in">dir</span>(data)</span><br><span class="line"> <span class="keyword">for</span> member <span class="keyword">in</span> members:</span><br><span class="line"> membervalue = <span class="built_in">getattr</span>(data,member)</span><br><span class="line"> <span class="built_in">print</span> <span class="built_in">format</span>%(member, membervalue)</span><br><span class="line"> </span><br><span class="line">monitorManager.addMessageCallback(ANY_job,ANY_message_type,printMessages,<span class="literal">None</span>)</span><br></pre></td></tr></table></figure><h2 id="实例">1.2. 实例¶</h2><p>现在我拉伸一块被焊接的钢板,想让他在位移达到1mm的时候停下。</p><p>首先对想要监控的区域做一个集合,这里设了点节点52作为监视集合,可以看到.inp文件里会出现如下关键字句。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">**********</span><br><span class="line">*Nset,nset=monitor, instance=mainplate-1 52,</span><br><span class="line">**********</span><br></pre></td></tr></table></figure><p>*<em>这一句是设置集合的时候自动生成,当然自己添加关键句也是可以的。</em></p><p>其次,在想要监控输出的分析步里,输入参数,这里想要测量的是y方向的位移(U2),关键句如下:</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">**********</span><br><span class="line">*Step,name=Step-1, nlgeom, inc=100</span><br><span class="line">compress dome</span><br><span class="line">*Static, riks</span><br><span class="line">0.2, 1., 1e-05,1.0, , monitor, 2, -3.7</span><br><span class="line">.....</span><br><span class="line">*Monitor, dof=2, node=monitor, frequncy=1#(这个需要自己添加)</span><br><span class="line">*End Step</span><br><span class="line">**********</span><br></pre></td></tr></table></figure><p>参数:<br>dof=2 指U2位移<br>node=monitor是指监视名为monitor的集合<br>frequecy=1监视的频率,可以根据自己的分析步调整,一般为1.</p><hr><p>python 思路</p><ol><li>定义函数 monitorDataValue(), 来输出分析的时间(data.time)和数值(data.value)</li></ol><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">monitorDataValue</span>(<span class="params">jobName, messageType, data, userData</span>):</span></span><br><span class="line"> <span class="built_in">print</span> <span class="string">"%-8s %s"</span>%(data.time, data.value)</span><br></pre></td></tr></table></figure><ol start="2"><li>修改函数monitorDataValue(),通过监视集合monitor的U2,使其位移超过1mm的时候就停止计算。</li></ol><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> data.value < -<span class="number">1</span> : </span><br><span class="line"> mdb.jobs[jobName].kill()</span><br></pre></td></tr></table></figure><ol start="3"><li>调整addMessageCallback()函数中的参数</li></ol><ul><li>将参数ANY_job赋值’123‘。(这里job的文件名为123)</li><li>将信息类型ANY_Message_type调整为 MONITOR_DATA。</li><li>将回调函数名字由printMessages调整为monitorDataValue</li></ul><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">monitorManager.addMessageCallback(<span class="string">'123'</span>, MONITOR_DATA,</span><br><span class="line"> monitorDataValue, <span class="literal">None</span>) </span><br></pre></td></tr></table></figure><ol start="4"><li>通过CAE或者abaqus command里的’abaqus CAE script = <a href="http://xx.py">xx.py</a>‘来运行。</li></ol><p><strong>完整代码如下</strong></p><h2 id="code6">1.3. 12345678910111213141516# -* - coding:UTF-8 -*-from abaqus import * from abaqusConstants import * import jobfrom jobMessage import *def monitorDataValue(jobName, messageType, data, userData): print "%-8s %s"%(data.time, data.value) if data.value < -1 : mdb.jobs[jobName].kill()monitorManager.addMessageCallback('123', MONITOR_DATA, monitorDataValue, None) job = mdb.JobFromInputFile('123', '123.inp')job.submit() ¶</h2><h1 id="运行结果">2. 运行结果¶</h1><p><img src="https://img-blog.csdnimg.cn/20210215174127684.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thZWRlMHYw,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p><hr><p><strong>拓展:</strong><br>监视器的功能很强大,可以结合python对很多参数进行监控和控制,比如还可以监控载荷,监控应变,来控制分析步的跳过,中止,以及输出变量之类的。</p><hr><p>参考:<br>曹金凤,王旭春,孔亮:Python语言在Abaqus中的应用,机械工业出版社,2011.7</p>]]></content>
<summary type="html"><p><img src="https://img.shields.io/badge/Abaqus-V.2020-blue?logo=Dassault%20Syst%C3%A8mes" alt="abaqus"></p>
<h1 id="运用python对abaqus进行监控">1. 运用python对abaqus进行监控¶</h1>
<p>在通过abaqus进行计算时,很多时候通过监视器或者查看.sta文件是太清楚解析算到哪一步的。<br>
<strong>运用python对abaqus CAE内置的监视器进行监控管理,特别对于非线性的分析能可以最大限度计算得到自己想要的数据,减少计算成本。</strong></p></summary>
<category term="Python" scheme="https://www.chenyu-k.com/categories/Python/"/>
<category term="Abaqus" scheme="https://www.chenyu-k.com/tags/Abaqus/"/>
<category term="Python" scheme="https://www.chenyu-k.com/tags/Python/"/>
</entry>
</feed>