{"id":282,"date":"2016-01-16T16:22:07","date_gmt":"2016-01-16T23:22:07","guid":{"rendered":"https:\/\/supermediocre.org\/?p=282"},"modified":"2022-03-05T09:07:13","modified_gmt":"2022-03-05T16:07:13","slug":"using-the-math-to-shape-bars","status":"publish","type":"post","link":"https:\/\/supermediocre.org\/index.php\/2016\/01\/16\/using-the-math-to-shape-bars\/","title":{"rendered":"Putting the Math to Work"},"content":{"rendered":"<p>Finding the beam theory papers was just a baby step to designing my own bars. What I needed was software to apply the math. It may have been possible to write the software from the math in the papers, but software like that can be very difficult to write and debug, especially given my\u00a0very tenuous grasp on the mechanical engineering concepts that underlie it. My breakthrough moment was when I found a masters thesis on the web that was written by\u00a0Mingming Zhao. The paper, called &#8220;Automatic multi-modal tuning of idiophone bars,&#8221; utilized the standard beam theory to compute the bar shapes, but most importantly, the appendix contained the actual Matlab code that applied the beam theory!<\/p>\n<p>Comments in the code indicated that is was a modified version of software\u00a0written by Dr Rodney Entwistle. So I looked up the\u00a0Entwistle paper too, which is cited below along with a web link. This paper provided some excellent background and context for the Zhao\u00a0paper.<\/p>\n<p>I started by copying\u00a0the Matlab functions from\u00a0the PDF file of the Zhao thesis to discrete files. To confirm that I had copied the code correctly,\u00a0my\u00a0first task was to verify that I could repeat the results from the paper. The following is a code snippet that was modified from code in appendix G.1 of the paper. It demonstrates the convergent nature of the algorithm. It takes as arguments the target frequency (300 Hz), the desired ratios for the 2nd and 3rd partials (4.0 and 9.8), the undercut functional form (cubic) and a\u00a0<em>seed<\/em>\u00a0for the iterative algorithm. Here is the run and the program output (captured in Matlab comments).<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"matlab\" data-enlighter-theme=\"enlighter\" data-enlighter-highlight=\"36\">bar_props.E = 17.96E9;\r\nbar_props.G = 6.75E9; \r\nbar_props.rho =  837.187565; \r\nbar_props.width = 0.06; \r\nbar_props.d0 = 0.01915; \r\nbar_props.bar_length = 0.3; \r\nclose all;\r\n[test_coeffs{1},test_reqs{1}]=main('ploton',true,'bar_props',bar_props,'selected_frequency',300,'overtone_ratios',[4;9.8],'profile','cubic', 'coeffs',[6;0.3;0.003]);\r\n%E=1.796e+10 G=6.750e+09 rho=837.2 width=0.06000 d0=0.01915 length=0.30000 profile=cubic\r\n%seed_coeffs = [6.000000000000; 0.300000000000; 0.003000000000]\r\n%=== Loop number: 1\r\n%   freq_new = [129.86691; 4.53455; 12.17812]\r\n%   freq_new = [129.86691; 4.53455; 12.17812]\r\n%   freq_new = [129.86705; 4.53455; 12.17811]\r\n% delta freq = [170.13310; -0.53455; -2.37811]\r\n%=== Loop number: 2\r\n%   freq_new = [319.67484; 4.13737; 10.36343]\r\n%   freq_new = [319.67484; 4.13737; 10.36343]\r\n%   freq_new = [319.67518; 4.13737; 10.36342]\r\n% delta freq = [-19.67482; -0.13737; -0.56343]\r\n%=== Loop number: 3\r\n%   freq_new = [299.01530; 3.97747; 9.66143]\r\n%   freq_new = [299.01530; 3.97747; 9.66143]\r\n%   freq_new = [299.01562; 3.97746; 9.66142]\r\n% delta freq = [0.98471; 0.02253; 0.13857]\r\n%=== Loop number: 4\r\n%   freq_new = [299.96624; 3.99930; 9.79651]\r\n%   freq_new = [299.96623; 3.99930; 9.79651]\r\n%   freq_new = [299.96656; 3.99930; 9.79650]\r\n% delta freq = [0.03378; 0.00070; 0.00349]\r\n%=== Loop number: 5\r\n%   freq_new = [299.99992; 4.00000; 9.80000]\r\n%   freq_new = [299.99992; 4.00000; 9.80000]\r\n%   freq_new = [300.00024; 4.00000; 9.80000]\r\n% delta freq = [0.00009; -0.00000; -0.00000]\r\n%final freqs = [299.99991; 4.00000; 9.80000]\r\n%coeffs = [10.308557568566; 0.322686204614; 0.006247284721]\r\n<\/pre>\n<p>In the highlighted line at the end, you can see that the algorithm converged to the desired final frequency and ratios in just a handful of iterations. It also provided the \u00a0coefficients to the cubic that provided the desired overtones.<\/p>\n<p>The graphical output from this run is at the top of this post. The two figures show the computed bar shape with the bar lying upside down (i.e., with the undercut at the top of the plot). The top figure has an aspect ration of 1:1, and the bottom figure zooms the y axis to better show the curve shape. There are multiple profile because the figure redraws the computed profile after each iteration of the converging algorithm. The line corresponding to the most broad undercut came from the final iteration of the code.<\/p>\n<p>This was pretty exciting! I finally had working code that could predict modal frequencies as a function of a specified bar shape.<\/p>\n<h1>Using the Code To Design My Bars<\/h1>\n<p>As previously stated, I had decided to design my bars to conform to the &#8220;double minimum&#8221; shape that I had observed on most of the commercial xylophones. To gain experience, I set out with the following plan in mind:<\/p>\n<ol>\n<li>Use the software to design a &#8220;double-minimum&#8221; bar.<\/li>\n<li>Fabricate a &#8220;test bar&#8221; out of some inexpensive wood (i.e., not Rosewood) that conformed to the computed\u00a0shape.<\/li>\n<li>Measure the frequency modes of the test bar to evaluate the accuracy of the predictions.<\/li>\n<\/ol>\n<h2>Step 1 &#8211; Designing My Test Bar<\/h2>\n<p>I chose a cubic function for the undercut profile. The choice was motivated by the fact that the cubic profile could realize the\u00a0desired double-minimum shape, but the parabola would have limited the shape to a simple arch shape. The math that computes the bar shape required information about the material type. The code needs the following parameters:<\/p>\n<ul>\n<li>Young&#8217;s modulus (E) &#8211; This is also sometimes called the &#8220;bulk modulus&#8221; and can be thought of as the stiffness of the wood.<\/li>\n<li>The shear modulus (G) &#8211; This is harder to describe, but I found a good description <a href=\"https:\/\/www.physicsforums.com\/threads\/youngs-modulus-and-elastic-modulus.13829\/\" target=\"_blank\" rel=\"noopener\">here<\/a>. To quote &#8220;the shear modulus is harder to talk about, but easiest to demonstrate: take a thick stack of paper (like a phone book) and with your hand on the top, push horizontally. The layers of the stack will shear and the top of the stack will move while the bottom stays put. All objects can be thought of as layers of material. How easily will these layers separate from each other? The shear modulus relates how the top layer of a material will move in relation to the bottom layer.&#8221;<\/li>\n<li>The density (rho) &#8211; This is just the mass divided by the volume of the material<\/li>\n<\/ul>\n<p>I measured the density directly, by measuring a prismatic section of the wood and weighing it. I computed the density as 650 kg\/m^3.<\/p>\n<p>The moduli were harder to come by. I found the following reference in the Orduna-Bustamante paper previously cited: &#8220;N . E. Molin, L-E. Lindgren, and E. V. Jansson, &#8216;Parameters \u00a0of violin\u00a0plates and their influence on the plate modes,&#8217;J . Acoust.S oc.A m. 83,<br \/>\n281-291 (1988). Ratios of Young&#8217;s modulus in the longitudinal direction\u00a0to the shear modulus are reported as E\/G=22.1 for spruce wood and\u00a0<strong>E\/G = 6.9 for maple wood<\/strong>.&#8221;<\/p>\n<p>OK, so given Young&#8217;s modulus, I could compute the shear modulus. I found a value of E=12.6 GPa <a href=\"http:\/\/www.wood-database.com\/lumber-identification\/hardwoods\/hard-maple\/\" target=\"_blank\" rel=\"noopener\">here<\/a>. I found a second reference <a href=\"http:\/\/annals-wuls.sggw.pl\/files\/files\/fwt\/fwt2011no75art02.pdf\" target=\"_blank\" rel=\"noopener\">here <\/a>that gave E=12.6 Gpa. So I split the difference and set E=12.5 Gpa.<\/p>\n<p>The algorithm to compute the bar profile needs a &#8220;seed&#8221; to start its iteration. I used a photograph of the Yamaha bar to compute\u00a0coefficients of\u00a0a cubic that approximated the bar shape. However, there was a snafu; the algorithm failed to converge to a solution. It uses a fairly basic\u00a0Newton-Raphson method of minimization to approach the solution. I am not sure why, but this had some problems. I could have probably worked out why this was the case, but I rather chose to use a Matlab minimizer called <em>fmincon<\/em> that I was familiar with. An advantage of this minimizer is that you can set constraints on the minimization, like disallowing solutions that yield a bar that is too thin. With the code modified to use fmincon, the algorithm converged! Here is the code that I ran:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"matlab\" data-enlighter-highlight=\"23\">%20150207 - Design for longest bar (made of Maple)\r\n%Properies from PPT file (Maple Wood Properties)\r\nwood_props.E = 12.5e+9; %\r\nwood_props.G = wood_props.E\/6.9;  %\r\nwood_props.rho =  650; \r\nwood_props.nu=(wood_props.E\/(2*wood_props.G))-1; %Poisson's ratio\r\n\r\nload('results_dir\/20150201_AllResults.mat','AllResults');\r\nbar_num=1;\r\nresults=AllResults{bar_num};\r\nComment='Bar #01 (Maple)';\r\nbp=results.inputs.bar_props;\r\nbp.E=wood_props.E;\r\nbp.G=wood_props.G;\r\nbp.rho=wood_props.rho;\r\nbp.nu=wood_props.nu;\r\nnum_elements=300;\r\nclose all    \r\n[coeffs,freqs,inputs,opt_results]=main('ploton',true,'bar_props',bp,'selected_frequency',bp.frequency, 'coeffs',results.coeffs, ...\r\n    'number_of_elements',num_elements, 'opt_method', results.inputs.opt_method,'lb',results.inputs.lb,'ub',results.inputs.ub,'weights',results.inputs.weights);\r\n\r\n%delta freq = [0.00016; -0.00005; -1.51121\r\n%final freqs = [350.81548; 3.00005; 7.51121\r\n%coeffs = [40.559582736574; -3.643168079495; 0.015502032584]\r\n\r\n<\/pre>\n<p>The highlighted line shows that the algorithm gave frequency ratios for the overtones of 3.00005 and 7.51121. The first overtone was dead on, but the second overtone failed to achieve the desired ratio of 6. I tried many variations of the minimizer, but could not coerce it to yield the desired value of r3 (shorthand for the ratio of the third partial to the fundamental). I don&#8217;t know why this is the case. Perhaps it is not possible to yield the desired overtone ratio with a cubic function. In any case, as previously stated, I decided to forgo tuning the third overtone, so I didn&#8217;t work this problem further.<\/p>\n<p>Here is a figure illustrating the shape of the resulting bar.<\/p>\n<figure id=\"attachment_310\" aria-describedby=\"caption-attachment-310\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/supermediocre.org\/wp-content\/uploads\/2016\/01\/maple_and_rosewood_bar.png\" rel=\"lightbox[282]\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-310\" src=\"https:\/\/supermediocre.org\/wp-content\/uploads\/2016\/01\/maple_and_rosewood_bar-300x225.png\" alt=\"Shape of resulting F4 bar.\" width=\"300\" height=\"225\" srcset=\"https:\/\/supermediocre.org\/wp-content\/uploads\/2016\/01\/maple_and_rosewood_bar-300x225.png 300w, https:\/\/supermediocre.org\/wp-content\/uploads\/2016\/01\/maple_and_rosewood_bar.png 675w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-310\" class=\"wp-caption-text\">Shape of resulting F4 bar.<\/figcaption><\/figure>\n<p>The red profile in this bar corresponds to Maple. The blue profile was computed using the properties of Rosewood. I plotted both to assess the difference between the two materials.<\/p>\n<p>Yee-haw! This seems kind of reasonable. Next step &#8211; make the bar out of wood. You&#8217;ll hear more about that in the next post (if anyone is still with me&#8230;).<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>References<\/strong><\/span><\/p>\n<p>Entwistle, R.D. and McGrechan, S.R. 2007. Geometric Shape <a href=\"http:\/\/www.acoustics.asn.au\/conference_proceedings\/ICSV14\/papers\/p248.pdf\">Identification for\u00a0Multi-Mode Tuning of Percussion Instrument Bars<\/a>. Proceedings of the 14th\u00a0International Congress on Sound and Vibration. Cairns, Australia, 9-12 July 2007.<\/p>\n<p>Zhao, Mingming. 2011. &#8220;<a href=\"http:\/\/espace.library.curtin.edu.au\/R?func=dbin-jump-full&amp;local_base=gen01-era02&amp;object_id=179150\" target=\"_blank\" rel=\"noopener\">Automatic multi-modal tuning of idiophone bars<\/a>,&#8221; Masters Thesis, \u00a0M.Phil. Curtin University, School of Civil<br \/>\nand Mechanical Engineering, Department of Mechanical Engineering<\/p>\n<p>Stone, B. 1992. &#8220;The receptances of beams, in closed form, including the effects of\u00a0shear and rotary inertia,&#8221; Journal of Mechanical Engineering Science 206 (2): 87-94.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Finding the beam theory papers was just a baby step to designing my own bars. What I needed was software to apply the math. It may have been possible to write the software from the math in the papers, but software like that can be very difficult to write and debug, especially given my\u00a0very tenuous &hellip; <a href=\"https:\/\/supermediocre.org\/index.php\/2016\/01\/16\/using-the-math-to-shape-bars\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Putting the Math to Work<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":283,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[3],"class_list":["post-282","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-xylophone","tag-xylophone"],"_links":{"self":[{"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/posts\/282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/comments?post=282"}],"version-history":[{"count":30,"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/posts\/282\/revisions"}],"predecessor-version":[{"id":1037,"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/posts\/282\/revisions\/1037"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/media\/283"}],"wp:attachment":[{"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/media?parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/categories?post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/supermediocre.org\/index.php\/wp-json\/wp\/v2\/tags?post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}