text:
ASU Research Park Celebrates 30 Years

How do you turn a political defeat into a big win, you look at your options, decide where you want to go, and you do it.  That is what a group of valley visionaries did in the early 1980′s when the state decided that only the University of Arizona could should have an agriculture program. That left Arizona State University with a large working farm that needed to be taken down. They could have sold the land for quick profit.  But instead they looked at options that would provide the most long-term benefit to the school, the state, and the local community.
The result, thirty years ago, was the ASU Research Park.  Located just west of the 101 Loop between Warner and Elliot roads, the Park is now a vibrant and thriving hot-spot of technical innovation and realization.  This is not an incubator where people try to be successful in technology, this is where people who are successful with technology come to get stuff done.
PADT is pleased to own a building in the Park, the PADT Innovation Center, where our headquarters are located along with three other business that lease space from us.  We have found the park to be a supportive place, centrally located, with great facilities for our employees.

The event was marked with a breakfast gathering of tenants, Tempe officials, Park board members, and representatives from ASU. Dr. Michael Crow, the President of ASU gave a great speech on how the park in particular helped move ASU towards being a true research university. He stressed that unlike in most places, ASU didn’t plan and study and move slowly. They wanted to become a research university and if you want to be a research university, you need a research park. So they built a research park, and in the end, a very successful one.

Some interesting facts about the park:

• Home to 49 companies with a total of over 4,500 employees
• Generates over $2,000,000 annually for ASU • Has a$816,000,000 annual impact on the Arizona economy, generating 11,180 jobs
• 89% of the park is leased, 26 Acres still available
• 1,790,000 sqft of office space, with 350,000 sqft under construction.

The mayor of Tempe, Mark Mitchel, was also on hand to share with the audience the strong impact that the park and ASU have had on the city and how the ASU Research Park is a true university-city initiative. In fact, Mr. Mitchel’s father, Harry Mitchel, was the mayor of Tempe thirty years ago and was one of the visionaries that helped make the park happen.

This aerial view, taken a few months ago, shows the new GoDaddy tech center being built in the lower right hand corner. The PADT innovation center is the upside-down check mark in the upper right corner.  PADT customers ViaSat and Amkor are both starting construction in the park right now.

To learn more, read the official press release: ASU Research Park Celebrates 30 Years – Press Release, or visit the park’s website: asuresearchpark.com.

NeruoEM’s Featured in Phoenix Business Journal

It’s always nice when a customer gets a mention in the local press. PADT is helping NeruoEM in the development of a “a self-contained head device to prevent and treat Alzheimer’s Disease (AD) with electromagnetic waves.”  Check out the write-up here.

There is not a lot we can say about the project or what we are doing for NeuroEM, but the website and article both give a good overview.

Needless to say, the older we all get, the more desire we have for this device to transition to an approved medical device.

Getting to know ANSYS – Rigid Body Dynamics (RBD)

This video is an introduction to ANSYS RBD – an add on module to ANSYS Mechanical for analyzing rigid mechanisms.

Pictures and Reflections from PADT’s 20th Anniversary Party

PADT held our 20th anniversary party at our primary offices in Tempe Arizona on April 10th. Despite the record high temperatures, around 400 people stop by to help us celebrate.  There was good food, good entertainment, and most importantly, good people.

A highlight of the event is that April 10th was proclaimed PADT day in Tempe!  That was an unexpected honor.

The only problem was not enough time to talk with everyone.  If you could not make it, no worries. We have several events planned throughout the year.

Here are some images that we captured:

Most of these pictures were taken by Aaron Moncur from PipelineDesign.

ACT Extension for a PID Thermostat Controller (PART 2)

(View part one of this series here.)

So, I’ve done a little of this Workbench customization stuff in a past life. My customizations involved lots of Jscript, some APDL, sweat and tears. I literally would bang my head against Eric Miller’s office door jamb wondering (sometimes out loud) what I had done to be picked as the Workbench customization guy. Copious amounts of alcohol on weeknights helped some, but honestly it still royally sucked. Because of these early childhood scars, I’ve cringed at the thought of this ACT thingy until now. I figured I’d been there, done that and I had zero, and I mean zero desire to relive any of it.

So, I resisted ACT even after multiple “suggestions” from upper management that I figure out something to do with it. That was wrong of me; I should have been quicker to given ACT a fair shot. ACT is a whole bunch better than the bad ol’ days of JScript. How is it better? Well, it has documentation… Also, there are multiple helpful folks back at Canonsburg and elsewhere that know a few things about it. This is opposed to the days when just one (brilliant) guy in India named Rajiv Rath had ever done anything of consequence with JScript. (Without him, my previous customization efforts would simply have put me in the mad house. Oh, and he happens to know a thing or two about ACT as well…)

Look Ma! My First ACT Extension!

In this post we are going to rig up the PID thermostat boundary condition as a new boundary condition type in Mechanical. In ACT jargon, this is known as adding a pre-processing feature. I’m going to refer you primarily to the training material and documentation for ACT that you can obtain from the ANSYS website on their customer portal. I strongly suggest you log on to the portal and download the training material for version 15.0 now.

Planning the Extension

When we create an ACT extension we need to lay things out on the file system in a certain manner. At a high level, there are three categories of file system data that we will use to build our extension. These types of data are:

1. Code. This will be comprised of Python scripts and in our case APDL scripts.
2. XML. XML files are primarily used for plumbing and for making the rest of the world aware of who we are and what we do.
3. Resources. These files are typically images, icons, etc… that spice things up a little bit.

Any single extension will use all three of these categories of files, and so organizing this mess becomes priority number one when building the extension. Fortunately, there is a convention that ACT imposes on us to organize the files. The following image depicts the structure graphically.

We will call our extension PIDThermostat. Therefore, everywhere ExtensionName appears in the image above, we will replace that with PIDThermostat in our file structure.

Creating a UI for our Load

The beauty of ACT is that it allows us to easily create professional looking user experiences for custom loads and results. Let’s start by creating a user interface for our load that looks like the following:

As you can see in the above user interface, all of the controls and inputs for our little PID controller that we designed in Part 1 of this blog series are present. Before we discuss how we create these user elements, let’s start with a description of what they each mean.

The first item in the UI is named Heat Source/Sink Location. This UI element presents to the user a choice between picking a piece of geometry from the model and specifying a named selection. Internal to the PID controller, this location represents where in the model we will attach the control elements such that they supply or remove energy from this location. ACT provides us two large areas of functionality here. First, it provides a way to graphically pick a geometric item from the model. Second, it provides routines to query the underlying mesh associated with this piece of geometry so that we can reference the nodes or elements in our APDL code. Each of these pieces of functionality is substantial in its size and complexity, yet we get it for free with ACT.

The second control is named Temperature Monitor Location. It functions similarly to the heat source/sink location. It gives the user the ability to specify where on the model the control element should monitor, or sense, the temperature. So, our PID controller will add or remove energy from the heat sink/source location to try to keep the monitor location at the specified set point temperature.

The third control group is named Thermostat Control Properties. This group aggregates the various parameters that control the functionality of the thermostat. That is, the user is allowed to specify gain values, and also what type of control is implemented.

The forth control group is named Thermostat Setpoint Properties. This group allows the user to specify how the setpoint changes with time. An interesting ACT feature is implemented with this control group. Based on the selection that the user makes in the “Setpoint Type” dropdown, a different control is presented below for the thermostat setpoint temperature. When the user selects, “User Specified Setpoint” then a control that provides a tabular input is presented. In this case, the user can directly input a table of temperature vs time data that specifies how the setpoint changes with time. However, if the user specifies “Use Model Entity as Setpoint” then the user is presented a geometry picker similar to the controls above to select a location in the model that will define the setpoint temperature. When this option is selected, the PID controller will function more like a follower element. That is, it will try to cause the monitor location to “follow” another location in the model by adding or removing energy from the heat source/sink location. The offset value allows the user to specify a DC offset that they would like to apply to the setpoint value. Internally, this offset term will be incorporated into the constraint equation averaging method to add in the DC offset.

Finally, the last control group allows the user to visualize plots of computed information regarding the PID controller after the solution is finished. Normally this would be presented in the results branch of the tree; however, the results I would like to present for these elements don’t map cleanly to the results objects in ACT. (At least, I can’t map them cleanly in my mind…) More detail on the results will be presented below.

So, now that we know what the control UI does, let’s look at how to specify it in ACT

Specifying the UI in XML

As mentioned at the beginning, ACT relies on XML to specify the UI for controls. The following XML snippet describes the entire UI.

<extension version=“1″ name=“ThermalTools”>

<guid shortid=“thermaltools”>852acb16-4731-4e91-bd00-b464be02b361</guid>

<script src=“thermaltools.py” />

<interface context=“Mechanical”>

<images>images</images>

<callbacks>

<oninit>initThermalToolsToolbar</oninit>

</callbacks>

<toolbar name=“thermtools” caption=“Thermal Tools”>

caption=“PID Thermostat Control”>

<callbacks>

</callbacks>

</entry>

</toolbar>

</interface>

<simdata context=“Mechanical”>

<callbacks>

<getcommands location=“post”>writePIDThermostatPost</getcommands>

<onremove>removePIDThermostat</onremove>

<onsuppress>suppressPIDThermostat</onsuppress>

<onunsuppress>unsuppressPIDThermostat</onunsuppress>

<oncleardata>cleardataPIDThermostat</oncleardata>

</callbacks>

<property name=“ConnectionGeo”  caption= “Heat Source/Sink Location”

control=“scoping”>

<attributes selection_filter=“vertex|edge|face” />

</property>

<property name=“MonitorGeo”  caption= “Temperature Monitor Location”

control=“scoping”>

<attributes selection_filter=“vertex|edge|face|body” />

</property>

<propertygroup name=“ControlProperties” caption=“Thermostat Control Properties”

display=“caption”>

<property name=“ControlType” caption=“Control Type”

control=“select” default=“Both Heat Source and Sink”>

<attributes options=“Heat Source,Heat Sink,Both Heat Source and Sink”/>

</property>

<property name=“ProportionalGain” caption=“Proportional Gain”

control=“float” default=“0″/>

<property name=“IntegralGain” caption=“Integral Gain”

control=“float” default=“0″/>

<property name=“DerivativeGain” caption=“Derivative Gain”

control=“float” default=“0″/>

</propertygroup>

<propertygroup name=“SetpointProperties” caption=“Thermostat Setpoint Properties”

display=“caption”>

<propertygroup name=“SetpointType” display=“property” caption=“Setpoint Type”

control=“select” default=“User Specified Setpoint”>

<attributes options=“User Specified Setpoint,Use Model Entity as Setpoint”/>

<propertytable name=“SetPointTemp” caption=“Thermostat Set Point Temperature”

display=“worksheet” visibleon=“User Specified Setpoint”

control=“applycancel” class=“Worksheet.PropertyGroupEditor.PGEditor”>

<property name=“Time” caption=“Time” unit=“Time” control=“float”></property>

<property name=“SetPoint” caption=“Set Point Temperature”

unit=“Temperature” control=“float”></property>

</propertytable>

<property name=“SetpointGeo”  caption= “Setpoint Geometry”

visibleon=“Use Model Entity as Setpoint” control=“scoping”>

<attributes selection_filter=“vertex|edge|face|body” />

</property>

</propertygroup>

<property name=“SetpointOffset” caption=“Offset” control=“float” default=“0″/>

</propertygroup>

<propertygroup name=“Results” caption=“Thermostat Results” display=“caption”>

<property name=“ViewResults” caption=“View Results?” control=“select” default=“No”>

<attributes options=“Yes,No”/>

<callbacks>

<onvalidate>onViewPIDResults</onvalidate>

</callbacks>

</property>

</propertygroup>

</simdata>

</extension>

Describing this in detail would take far longer than I have time for now, so I’m going to direct you to the ACT documentation. The gist of it is fairly simple though. XML provides a structured, hierarchical mechanism for describing the layout of the UI. Nested structures appear as child widgets of their parents. Callbacks are used within ACT to provide the hooks into the UI events so that we can respond to various user interactions. Beyond that, read the docs!! And, hey, before I hear any whining remember that in the old days of Jscript customization there wasn’t any documentation! When I was a Workbench Customization Kid we had to walk uphill, both ways, barefoot, in 8’ of snow for 35 miles… So shut it!

Making the Magic Happen

So, the UI is snazzy and all, but the heavy lifting really happens under the hood. Ultimately, what ACT provides us, when we are creating new BCs for ANSYS, is a clever way to insert APDL commands into the ds.dat input stream. Remember that at its core all Mechanical is, is a glorified APDL generator. I’m sure the developers love me reducing their hard labor to such mundane terms, but it is what it is… So, at the end of the day, our little ACT load objects are nothing more than miniature APDL writers. You thought we were doing something cool…

So, the magic happens when we collect up all of the input data the user specifies in our snazzy UI and turn that into APDL code that implemented the PID controller. This is obviously why I started by developing the APDL code first outside of WB. The APDL code is the true magic. Collecting up the user inputs and writing them to the ds.dat file occurs inside the getcommands callback. If you look closely at the XML code, you will notice two getcommands callbacks. The first one calls a python function named: writePIDThermostatLoad. This callback is scheduled to fire when Mechanical is finished writing all of the standard loads and boundary conditions that it implements natively and is about to write the first APDL solve command. Our commands will end up in the ds.dat file right at this location. I chose this location for the following reason. Our APDL code for the PID thermostat will be generating new element types and new nodes and elements not generated by Workbench. Sometimes workbench implements certain boundary conditions using surface effect element types. So, these native loads and boundary conditions themselves may generate new elements and element types. Workbench knows about those, because it’s generating them directly; however, it has no idea what I might be up to in my PID thermostat load. So, if it were to write additional boundary conditions after my PID load, it very well might reuse some of my element type ids, and even node/element ids. The safer thing to do is to write our APDL code so that it is robust in the presence of an unknown maximum element type/real constant set/node number/etc… Then, we insert it right before the solve command, after WB has written all of its loads and boundary conditions. Thus, the likelihood of id collisions is greatly reduced or eliminated.

Note, too, that ACT provides some utility functions to generate a new element type id and increment the internal counter within Workbench; however, I have found that these functions do not account for loads and boundary conditions. Therefore, in my testing thus far, I haven’t found them safe to use.

The second getcommands callback is setup to fire when Workbench finishes writing all of the solve commands and has moved to the post processing part of the input stream. I chose to implement a graphing functionality for displaying the relevant output data from the PID elements. Thus, I needed to retrieve this data from ANSYS after the solution is complete so that I can present it to the user. I accomplished this by writing a little bit of APDL code to enter /post26 and export all of the data I wish to plot to a CSV file. By specifying this second getcommands callback, I could instruct Workbench to insert the APDL commands after the solve completed.

Viewing the Results

Once the solution has completed, clicking on the “View Results?” dropdown and choosing “Yes” will bring up the following result viewer I implemented for the PID controller. All of the graphing functionality is provided by ACT in an import module called “chart”. This result viewer is simply implemented as a dialog with a single child control that is the ACT chart widget. This widget also allows you to layout multiple charts in a grid, as we have here. As you can see, we can display all of the relevant output data for the controls cleanly and efficiently using ACT! While this can also be accomplished in ANSYS Mechanical APDL, I think we would all agree that the results are far more pleasing visually when implemented in ACT.

Where Do We Go from Here?

Now that I’ve written an ACT module, my next steps are to clean it up and try to make it a little more production ready. Once I’m satisfied with it, I’ll publish it on this blog and on the appropriate ANSYS library. Look for more posts along the way if I uncover additional insights or gotchas with ACT programming. I will leave you with this, however. If you have put off ACT programming you really should reconsider! Being mostly new to ACT, I was able to get this little boundary condition hooked up and functioning in less than a week’s time. Given the way the user interface turned out and the flexibility thus far of the control, I’m quite pleased with that. Without the documentation and general availability of ACT, this effort would have been far more intense. So, try out ACT! You won’t be disappointed.

Posted in The Focus | | 1 Comment

Color 3D Printer Added to PADT’s Rapid Prototyping Product and Services Offering

PADT’s new Objet500 Connex3 is up and running, just in time for our 20th Anniversary party tonight.  The latest machine from Stratasys is the first true 3D Color Printer that allows users to print accurate and durable parts in whatever combination of color they want, including tinted transparent material. The machine is comfortably nestled between our FORTUS 400 and FORTUS 250MC.

We are especially pleased to have several executives and support people from Stratasys, the manufacturer of this machine, here for our party tonight.  They will be around to answer questions and will be offering a brief presentation on their technology as well.

Yesterday we successfully ran the standard “wrench” demo models:
And overnight we ran some more sample parts along with a printout of a 3D FEA result on a valve model:
The parts are still inside the support material, so you can’t see all the colors. Have no fear, we will be blogging about the FEA model very shortly.

PADT has been offering this machine for sale since its introduction in February and we have already sold one and have several other users about to purchase.  The advantages of having a color part without having to paint on are significant.  With our own machine we can now build benchmark parts for potential buyers and we can also offer color printing as part of our Rapid Prototyping services

We will be showing off this machine, along with everything else PADT does, at our party tonight.  But if you can’t make it and would like to learn more, just reach out to our sales team at sales@padtinc.com, our prototyping services team at rp@padtinc.com or just give us a call at 480.813.4884.

UPDATE:

Here is the cleaned valve displacement 3D Plot:

Ready for a Tech Party? We Are! PADT’s 20th Anniversary Party is Tomorrow Night

Everyone here at PADT is working hard on their day-to-day tasks and getting ready for the 20th Anniversary Party tomorrow night from 5:30-9:00. The refreshments have been procured, ice is on order, and an appointment has been set to go get the cake. In light of tomorrows high temps, we even ordered two coolers to keep everyone comfortable, so “it’s too hot” is no longer a valid excuse.

Tomorrow around noon, all of PADT’s employees will gather together for a special anniversary pictures, attend a company meeting, then set everything up.

All we need now is you!

Even though we have been suffering from construction delays, the new demo & server room is finished enough to show everyone around.  In the new room, will be highlighting our CUBE HPC hardware and the new Objet 3D Color Printer in this new facility, along with the scanners and other Additive Manufacturing machines you have all come to know and count on:

Here are some reminders for those that can make it:

• Everyone is invited, no need to RSVP. Just come and bring a friend.
• If you are social network kind of person, please tag any posts: #padt20
• We will have plenty of food and drink
• Entertainment will be provided for the young (and young at heart) with a bouncy-house and a magician
• We will be featuring music from 1994… but it is an engineering event so don’t expect a lot of dancing.
• Come at any time you want. Speeches and door price drawings will be from 6:30-7:00
• We will be handing out some swag, first come first serve for t-shirts and slap bracelets.

For those of you who could not make it, a big thank you for all the fantastic best wishes and congratulations.  We really appreciate all the support everyone has given us over the past 20 years.

Getting to know ANSYS – Icepak

As part of our “Getting to know ANSYS” video series, this video is an introduction to ANSYS Icepak – an electronics thermal analysis package in the ANSYS Product Suite.

“Getting to know ANSYS” Video series

The ANSYS Product Suite contains a large number of modules that are each tailored for a particular area in the simulation and analysis world.  We, at PADT, realize that many of our customers are not aware or are confused at where each of these modules fits in to the analysis spectrum.

The “Getting to know ANSYS” videos will hopefully help everyone to understand these modules a little better.  Each video will focus on one module and will showcase the following in a mixture of presentations and mini-demos:

• What each module is
• What are its capabilities
• Why is it useful
• Who can benefit from using it

The videos will be in the “Getting to know ANSYS” playlist on PADT’s Youtube Channel.

Please feel free to let us know how the videos are and definitely let us know which module that you are interested in and that you’d like to see next. That will help us to plan these future videos accordingly.

You can reach out to me directly at manoj.mahendran@padtinc.com for questions or followups to these or the Focus Video Tips” videos.

Thanks!


text:
Galois Group of $x^5+ 5x^3 + 5x + 1$.

I've been asked to determine the Galois Group of $x^5+ 5x^3 + 5x + 1$. This is what I know so far.

1) The polynomial is irreducible.

2) Its discriminant is $78125=5^7$

Since the discriminant is not a square, the Galois group should be $S_5$ or $F_{20}$. How can I know? In case it was $F_{20}$, is it solvable?

• What methods have you learned for computing Galois groups already? (By the way, a computer algebra system will quickly tell you what the answer is, but that is not the same as figuring out an argument that proves the result independently of computers.) – KCd Jan 10 '14 at 22:50
• I know the general strategies to compute Galois groups of cubic and quartic polynomials, and its definition as the group of Q-endomorphisms of the splitting field. Nothing for quintics, though – Pesi442 Jan 10 '14 at 22:55
• IF it has exactly two nonreal roots, then the group is $S_5$, so first I'd check to see how many nonreal roots it has. That much is an exercise in 1st year Calculus. – Gerry Myerson Jan 10 '14 at 22:57
• Already checked, it has 4 non real roots. – Pesi442 Jan 10 '14 at 22:59
• Do you know Dedekind's theorem about the factorization of $f(x) \bmod p$ into irreducibles implying the existence of particular cycle types in the Galois group, e.g., mod 2 the polynomial is a linear times a quartic, so the Galois group over $\mathbf Q$ has an automorphism that acts on the roots as a permutation of cycle type $(1,4)$? – KCd Jan 10 '14 at 23:02

The paper Solving Solvable Quintics - D. S. Dummit shows the construction of a resolvent $$f_{20}$$ for the quintic such that $$f_{20}$$ has a rational root iff the Galois group is contained in $$F_{20}$$.

Let $$x_i$$ be roots of the general quintic.

Let $$\theta = x_{0} x_{1}^{2} x_{2} + x_{0}^{2} x_{2} x_{3} + x_{1} x_{2}^{2} x_{3} + x_{0} x_{1} x_{3}^{2} + x_{0}^{2} x_{1} x_{4} + x_{0} x_{2}^{2} x_{4} + x_{1}^{2} x_{3} x_{4} + x_{2} x_{3}^{2} x_{4} + x_{1} x_{2} x_{4}^{2} + x_{0} x_{3} x_{4}^{2}$$

Then we define $$f_{20}(x) = \prod_{\sigma} (x - \sigma \theta)$$ where the permutations $$\sigma \in S_5$$ act by permuting the variables $$x_{i}$$ of $$\theta$$. The product is taken over the whole orbit. This orbit has size 6. Note that $$5!/6 = 20$$.

Now $$f_{20}$$ is invariant under conjugation therefore it lies in the base field. Using symmetic polynomial calculations you may recover (the very long) formula (2) from the paper. The resolvent for our polynomial in particular is:

$$f_{20}(x) = x^{6} + 40 \, x^{5} + 250 \, x^{4} - 4375 \, x^{3} - 21875 \, x^{2} + 25000 \, x - 1187500$$

and $$(x-10)|f_{20}(x)$$ so combining this with your observation that the discriminant is nonsquare we find that the Galois group of this polynomial is $$F_{20}$$.

• Nice to have this explained. Hope it won't offend you if I tell that I like Oscar Lanzi's take even more. – Jyrki Lahtonen Jul 20 '20 at 11:31
• Not at all, I am very grateful that it was posted so I can see such an efficient solution! – river Jul 20 '20 at 11:37
• One way to seek the rational root more efficiently: render $x=5u$. Then all terms are divisible by $5^6=15625$ and a rational root for $u$ would have to divide $1187500/15625=76$. – Oscar Lanzi Jul 20 '20 at 12:38

There is no doubt that this is solvable. Render $$x=r-1/r$$ and show that $$r^5-1/r^5=-1$$. Thus $$r^5=(-1\pm\sqrt5)/2$$, etc, and the Galois group can't be larger than $$F_{20}$$.

• This is a fantastic solution! How would one come up with substitutions like $r - 1/r$? – river Jul 20 '20 at 10:23
• I happened to spot it from attempting to find geometric fifth root or angle wuintisection solutions in the past (that failed). If we put $x=2\sinh u$ into the equation the terms containing $u$ match with the five-times argument formula for hyperbolic sine, thus $\sinh 5u=-1/2$. This then implies that $2\sinh u =r-1/r$ implies $\sinh 5u=(-1/2)$. – Oscar Lanzi Jul 20 '20 at 10:27

We can use the Magma online calculator to find the Galois group of the equation $$f(x)= x^5 + 5 x^3 + 5 x + 1$$ in the field of rational numbers.

> P<x> := PolynomialRing(IntegerRing());
> f :=  x^5 + 5 * x^3 + 5 * x + 1;
>G:=GaloisGroup (f);
>G;
>IsCyclic (G);
>IsSolvable (G);

We can get that the Galois group of this equation in the rational number field has order 20 and is a solvable group:

This result is for reference only, and cannot replace theoretical analysis.

format: plain


text:
# Calculate the number of turns in air core inductor

Coil specification:

• Air core coil
• Length 790 mm
• Diameter 290 mm
• Wire guage 18 - 1 mm diameter

I need the number of turns to get an inductance of 150 mH.

While searching for calculating the number of turns, I found a lot of different formulas.

I know that we can calculate the inductance with the formula

$$L = \frac{\mu_0 N^2 A}{d}.$$

If I use it to get the number of turns, it gives 4 turns only.

I am also confused how this formula can calculate the inductance and not the turns.

• Is it Tesla coil? Change AWG for single layer @Dave Tweed suggestion. Weight 8 kg wire. Aug 9, 2022 at 14:54
• It is multilayer for solenoid coil
– Tito
Aug 9, 2022 at 14:57
• What frequency range is this operating at? Aug 9, 2022 at 16:04
• Main power Ac 220v - 50 hz
– Tito
Aug 9, 2022 at 18:22
• If the ratios of your dimensions are not fixed, then length = 81% of diameter gives you maximum inductance for a given length of wire in a single layer solenoid. Aug 9, 2022 at 18:49

Air core coil

Length 790mm

Diameter 290mm

Let me mention that air's magnetic permeability ($$\\mu_0\$$) is $$\4\pi\times 10^{-7} \frac{H}{m}\$$ and not unity.

Let's also start with the correct formula (and not what you wrote in the question): -

$$L = \dfrac{\mu_0\cdot N^2\cdot A}{\ell}$$

Where $$\l\$$ is the length of the solenoid. The enclosed area of a round solenoid is $$\A = \pi d^2 / 4\$$ for diameter $$\d\$$.

So, rearrange the formula to get: -

$$N = \sqrt{\dfrac{0.15\text{ H} \times 0.79\text{ m}}{4\pi\times 10^{-7} \frac{H}{m} \times 0.06605\text{ m}^2}} = 1195 \text{ turns}$$

Calculator double check: -

When I enter 1 for relative permeability the calculator inherently knows about $$\4\pi\times 10^{-7} \frac{H}{m}\$$.

I also confused how this formula can calculate the inductance and not the turns

It can calculate turns but you need to factor-in the correct value for the permeability of free-space. Good luck winding 1145 turns along a distance of 790 mm; I'd be considering a two-layer winding.

• For a single layer, he'll have to switch to AWG 22 wire. It will require about 1.1 km of wire, with a resistance of 56 ohms. Aug 9, 2022 at 14:52
• It is multilayer coil for solenoid
– Tito
Aug 9, 2022 at 15:14
• @Tito yes, that is what I suggested. Please take the 2 minute tour to understand why folk give their help for free. I'm saying this because you haven't previously formally selected any answers to your questions. I'm sure this is an oversight of course so, now is the time to remedy this. Any answers that need clarification just raise a new comment. Aug 9, 2022 at 15:17
• @tito your question says Diameter 290mm and that is 29 cm. Aug 9, 2022 at 15:18
• The errors you will get will be mainly due to the outer layer not fully coupling to the inner layer. You might need more like 5000 turns but that is just a broad estimate on my part. When layers don't couple properly the $N^2$ factor becomes more like $N^{1.5}$ for instance. Aug 9, 2022 at 15:39


text:
• 9
• 9
• 11
• 12
• 9

# Ideas for how to improve code

This topic is 2135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## [font=UsherwoodStd-Medium][font=UsherwoodStd-Medium]http://webEbenezer.n...ntegration.html . One area that needs work is settling on a coding convention and adhering to it -- the names of classes/functions/files aren't consistent. Thoughts on that are appreciated, but I hope there will be other ideas. Tia.[/font][/font]

##### Share on other sites
Consistency is nice, but as long as everything is relatively readable, it should be the least of one's concerns, IMHO.

I haven't looked very hard. Without spending a long time trying to figure out it's purpose, it's hard to be sure if it's fit for purpose. Also, a lot of it is headers without any implementation, so what I'm not sure what you're hoping to get out of this.

But...

I don't see any tests. bug_count(code without tests) >= bug_count(same code with tests). So that's one easy way of improving the code.

The "[color=#000000]malloc_never_null" function is also extremely weird, especially since it's used in a context where you know there's a maximum buffer size of 255 (which is peanuts for almost any system).

[color=#000000]I counted a grand total of 2 asserts

##### Share on other sites
 /* * Like new, we want to guarantee that we NEVER * return NULL. Loop until there is free memory. * */ static char* malloc_never_null (size_t const b) { char *p; do { p = static_cast<char*>(malloc(b)); } while ( p == NULL ); return p; }

This is just wrong, you should feel ashamed.. the reason new never returns a null pointer is because it throws an exception if it can't allocate the requested amount of memory.

Unless you disable exceptions in your specific compiler, then new can of course return null pointers (depending on implementation specifics).

##### Share on other sites

This is just wrong, you should feel ashamed.

There's no shame in doing something incorrectly.

##### Share on other sites

the reason new never returns a null pointer is because it throws an exception if it can't allocate the requested amount of memory.

Unless you disable exceptions in your specific compiler, then new can of course return null pointers (depending on implementation specifics).

To expand on this, [font=courier new,courier,monospace]new [/font]can be made to return [font=courier new,courier,monospace]NULL[/font]/[font=courier new,courier,monospace]nullptr [/font]upon failure if you use [font=courier new,courier,monospace]nothrow[/font]. In which case, [font=courier new,courier,monospace]new [/font]may return [font=courier new,courier,monospace]NULL[/font]. If there isn't any available memory when you request it, there probably won't be any the next time you request it 700 nanoseconds later, and there isn't much sense in getting stuck in a potentially infinite loop.

I'm curious as to why you're using [font=courier new,courier,monospace]malloc [/font]instead of [font=courier new,courier,monospace]new[/font].

While edd[sup]2[/sup] has a point about consistency not being critical to having a working product, I will say that I would be horribly frustrated if a project was inconsistent in its conventions.

This line (from MarshallingFunctions.hh):
(boolRep != 0) ? bl = true : bl = false;
is technically valid, but it goes against every normal use of the ternary operator. If you wanted it to be consistent with how the other 99.99% of the world programs, it would be:
bl = boolRep != 0;
or at most:
bl = (boolRep != 0) ? true : false;
If you really wanted to do it that way though, you could also do
if (boolRep != 0) b1 = true; else b1 = false;
which is slightly common (but depends on your coding conventions), but I'd say by far the most common are the first two I mentioned.

I will commend you on seeking to improve your code. It's not always easy to ask for a critical review. Edited by Cornstalks

##### Share on other sites

There's no shame in doing something incorrectly.

There's no good reason to use malloc in C++ anyway, especially if you're about to use it incorrectly.

If you really want "performance" (PLEASE PROFILE FIRST), then you can use the OS-specific HeapRealloc or POSIX realloc APIs and hide them behind an overloaded new operator.

##### Share on other sites

[quote name='Mihai Moldovan' timestamp='1335828424' post='4936216']
This is just wrong, you should feel ashamed.

There's no shame in doing something incorrectly.
[/quote]
+1. The only shame lies in not learning why it was incorrect.

##### Share on other sites

[quote name='Mihai Moldovan' timestamp='1335828424' post='4936216']
the reason new never returns a null pointer is because it throws an exception if it can't allocate the requested amount of memory.

Unless you disable exceptions in your specific compiler, then new can of course return null pointers (depending on implementation specifics).

To expand on this, [font=courier new, courier, monospace]new [/font]can be made to return [font=courier new, courier, monospace]NULL[/font]/[font=courier new, courier, monospace]nullptr [/font]upon failure if you use [font=courier new, courier, monospace]nothrow[/font]. In which case, [font=courier new, courier, monospace]new [/font]may return [font=courier new, courier, monospace]NULL[/font]. If there isn't any available memory when you request it, there probably won't be any the next time you request it 700 nanoseconds later, and there isn't much sense in getting stuck in a potentially infinite loop.

I'm curious as to why you're using [font=courier new, courier, monospace]malloc [/font]instead of [font=courier new, courier, monospace]new[/font].
[/quote]

I picked that code up from someone on line and haven't paid enough attention to it yet. It probably should use new.

While edd[sup]2[/sup] has a point about consistency not being critical to having a working product, I will say that I would be horribly frustrated if a project was inconsistent in its conventions.
[/quote]

I agree. It would be too arbitrary otherwise. What I may do is adopt one naming convention for my library and the generated code and another naming convention for the executables. I'm not really comfortable with lower case and underscores exclusively or all camel case. I'm going to work on the convention for the library first.

This line (from MarshallingFunctions.hh):
(boolRep != 0) ? bl = true : bl = false;
is technically valid, but it goes against every normal use of the ternary operator. If you wanted it to be consistent with how the other 99.99% of the world programs, it would be:
bl = boolRep != 0;
or at most:
bl = (boolRep != 0) ? true : false;
If you really wanted to do it that way though, you could also do
if (boolRep != 0) b1 = true; else b1 = false;
which is slightly common (but depends on your coding conventions), but I'd say by far the most common are the first two I mentioned.
[/quote]

I think I'll go with this one:
bl = (boolRep != 0) ? true : false;
This is a small thing, but these things add up. Edited by wood_brian

##### Share on other sites

Consistency is nice, but as long as everything is relatively readable, it should be the least of one's concerns, IMHO.

I haven't looked very hard. Without spending a long time trying to figure out it's purpose, it's hard to be sure if it's fit for purpose. Also, a lot of it is headers without any implementation, so what I'm not sure what you're hoping to get out of this.

There's an archive here that has all of the files.

But...

I don't see any tests. bug_count(code without tests) >= bug_count(same code with tests). So that's one easy way of improving the code.

The "[color=#000000]malloc_never_null" function is also extremely weird, especially since it's used in a context where you know there's a maximum buffer size of 255 (which is peanuts for almost any system).

[color=#000000]I counted a grand total of 2 asserts
[/quote]

You got it right. (There's more than two but they are in the segmented_array code by Leigh Johnston that I ship with the archive.) Perhaps you could show an example of where you would add an assert.

##### Share on other sites

Perhaps you could show an example of where you would add an assert.

As one example, you could be pedantic by changing (from MarshallingFunctions.hh)
inline void CstringCount (::cmw::Counter& cntr, char const* cstr) { marshalling_integer slen(::strlen(cstr)); slen.CalculateMarshallingSize(cntr); cntr.Add(slen.value); }
to:
inline void CstringCount (::cmw::Counter& cntr, char const* cstr) { assert(cstr != NULL); marshalling_integer slen(::strlen(cstr)); slen.CalculateMarshallingSize(cntr); cntr.Add(slen.value); }

Personally, I like to use [font=courier new,courier,monospace]assert[/font] whenever i have to deal with a pointer.


text:
# PHP class to send CRM records to Five9 API

I am experimenting with the Five9 API and setup a PHP class to deal with the addRecordstoList method.

The main issue this class was meant to solve over the traditional function found in their documentation is that the function must map the index of the array to the correct field. For instance, column 1 is populated by value of index 0 of the array. This would cause an issue when the lead array sent as a parameter has keys in a different order or includes optional fields. It throws the indexes off and information on the records list is out of order when sent over.

I would like some input on the class and how to make it faster and allow to sendtoFive9 function to be looped without overriding the array.

    //how the columns are mapped in the example provided by five9
$listUpdateSettings = array ( "fieldsMapping" => array ( array ( "columnNumber" => '1', "fieldName" => "number1", "key" => true ), array ( "columnNumber" => '2', "fieldName" => "first_ name", "key" => false ), array ( "columnNumber" => '3', "fieldName" => "last_ name", "key" => false) ); class five9{ //the fields mapped to five9 //initialize and empty array so there are no errors with array_push private static$listUpdateSettings = array("fieldsMapping" => array());

//maps field to five9 columns
protected function mapField($index,$field, $key = false){ //map the field to five9. Index must start at 1 not 0 //mapping fields this way allows flexibility in which order the parameter has its keys array_push( self::$listUpdateSettings["fieldsMapping"], array( "columnNumber" => $index + 1, "fieldName" =>$field, "key" => $key )); } //returns data array after being scrubbed protected function checkArray( array$lead){

//data sent to five9
$data = array(); //counter$i = 0;

//five9 requires the $field names outlined below foreach($lead as $field =>$value){
//make sure first_name is 3 characters or more
if( ($field == 'first_name' && strlen($field) > 3)){
$data[$i] = $value; //map the field in five9 self::mapField($i, $field); } //make sure last_name is 3 characters or more if($field == 'last_name' && strlen($field) > 3 ){ //add field to array$data[$i] =$value;
//map the field in five9
self::mapField($i,$field);
}
//if the field is a phone number
if( $field == 'number1' ){ //add field to array$data[$i] = preg_replace("/[^0-9]/", "",$value);
//map the field in five9
//this was they key for my instance
self::mapField($i,$field, true);
}
//if the field is a phone number
if( $field == 'number2' ){ //add field to array$data[$i] = preg_replace("/[^0-9]/", "",$value);
//setup column mapping in five9
self::mapField($i,$field);
}
//make sure the state is only two characters
if($field == 'state' && strlen($value) <= 2){
$data[$i] = $value; //setup column mapping in five9 self::mapField($i, $field); } //make sure the zip is only 5 characters if($field == 'zip' && strlen($value) == 5){ //add field to array$data[$i] =$value;
//setup column mapping in five9
self::mapField($i,$field);
}
//make sure memberid is an int
if($field == 'member_id' && is_numeric($value)){
$data[$i] = $value; //setup column mapping in five9 self::mapField($i, $field); } //increase the counter$i++;
}
//return the data array that is constructed
return $data; } static function sendToFive9(array$lead ){

//the conctructed array
$data = self::checkArray($lead);

//if the fields sent are all correct both arrays are the same size
if(sizeof($lead) === sizeof($data) ){

// Import the WSDL and authenticate the user.-----------------------------
$wsdl_five9 = "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl&user=$username";

//try to authenticate with five9
try{
$soap_options = array( 'login' => '$username',
'password' => '$password', 'trace' => true );$client_five9 = new SoapClient( $wsdl_five9 ,$soap_options );
}//if errors occur add the message to the response array
catch (Exception $e){$error_message = $e->getMessage();$response['error'] = $error_message; } //settings required by five9 self::$listUpdateSettings["skipHeaderLine"] = false;
self::$listUpdateSettings["cleanListBeforeUpdate"] = false; self::$listUpdateSettings["crmAddMode"] = 'ADD_NEW';
self::$listUpdateSettings["crmUpdateMode"] = 'UPDATE_SOLE_MATCHES'; self::$listUpdateSettings["listAddMode"] = 'ADD_IF_SOLE_CRM_MATCH';

//the default list for all new leads
$list = "test"; //prepare the query used to add the record to five9$query = array ( 'listName' => "$list", 'listUpdateSettings' => self::$listUpdateSettings,
'record' => $data ); //get the result from running the query //this will return an object$result = $client_five9->AddRecordToList($query);

//get the array of variables within the results object
$variables = get_object_vars($result);

//get the array of varaibles within the return array of objects
$resp = get_object_vars($variables['return']);

//if there was an error adding the record
if($resp['failureMessage'] != ""){$response['errors'] = $resp['failureMessage']; } //if it was successful either adding or updating if($resp['crmRecordsUpdated'] == 1 || $resp['crmRecordsInserted'] == 1){$response['success'] = true;
//reset the settings array so this function can be looped without passing the lists back and forth
self::$listUpdateSettings = array("fieldsMapping" => array()); } }//end if else{ //return the differences in the arrays usually caused due to improper names$reponse["errors"] = array_diff($lead,$data);

}

return $response; }//end function }  • For the first couple if statements, should it be checking the length of $value instead of $field? e.g. if( ($field == 'first_name' && strlen($field) > 3)){ – Sᴀᴍ Onᴇᴌᴀ Oct 6 '17 at 17:33 • In terms of readability, I think your functions are too big and it would be more readable if you split it up in multiple functions. Next to that, please adhere to PSR2. Also for readability and performance you should use elseif blocks instead of only ifs. Also, I would suggest using late static bindings: static:: instead of self:: – Mazzy Oct 8 '17 at 21:53 • @Mazzy thanks for the input will include in the next revision, I updated my answer below with some of the suggestions incorporated. – Orlando P. Oct 10 '17 at 13:28 ## 2 Answers Updating my answer after input from everyone. Posted this on Github but I am still working on it. <?php /** * This class uses five9 API to send records in various ways to a contact list * * @link https://github.com/opolanco23/PHP-Five9-API * @since 1.0.0 * * @package PHP Five9 API * @author Orlando Polanco <me@orlandopolanco.us> */ Class addRecordsToFive9{ /** * The username set outside of any function so it can be set * by any method required by the client code * * @since 1.0.0 * @access private * @var string$username    The username used to connect to five9.
*/
private static $username = ""; /** * The password set outside of any function so it can be set * by any method required by the client code * * @since 1.0.0 * @access private * @var string$password    The username used to connect to five9.
*/
private static $password = ""; /** * The array consists of keys that must match the name of fields inside your five9 contact field. * Each key is used to associate an array of settings to that field * supported data types are string, phone, int you may add as needed. * @since 1.0.0 * @access private * @var array$fields   (field name within five9) "key"  => array("type of data", min-length, max-length, is_key)
*/
private static $fields = array( "first_name" => array( 'type' => "string" , 'min' => 3, 'max' => 100, 'is_key' => false ), "last_name" => array( 'type' => "string" , 'min' => 3, 'max' => 100, 'is_key' => false ), "number1" => array( 'type' => "phone" , 'min' => 10, 'max' => 14, 'is_key' => true ), "number2" => array( 'type' => "phone" , 'min' => 10, 'max' => 14, 'is_key' => false ), "state" => array( 'type' => "string" , 'min' => 2, 'max' => 2, 'is_key' => false ), "zip" => array( 'type' => "int" , 'min' => 5, 'max' => 5, 'is_key' => false ), "member_id" => array( 'type' => "int" , 'min' => 5, 'max' => 20, 'is_key' => false ), ); /** * Constructor is not used for any processing yet * but could be used to Initialize username and password. * * @since 1.0.0 * @return null */ function __construct(){ /* call to DB or external file to retrieve username and password *$credentials = getCredentials();
* $this->$username = $credentials['username']; *$this->$password =$credentials['password'];
*/
}
/**
* Before Sending record to five9 the fields must be mapped with column number and the field name.
* Names of the fields must also match the names inside of the contact database.
*
* @since    1.0.0
* @param    array         $record the scrubbed array of lead data. * @param array$mappedFields    An array of fields being mapped to five9 along with there properties
* @param    integer       $index where to start the column count. Some functions require 1 others 0 * @return array$mappedFields    returns an array of arrays consisiting of the mappedFields
*/
protected function mapFields($record,$fields, $i){ foreach ($record as $key =>$value) {
//map the field to the five9 system
$mappedFields[] = array( "columnNumber" =>$i, "fieldName" => $key, "key" =>$fields[$key]['is_key'] );$i++;
}
return $mappedFields; } /** * Before Sending record to five9 the fields must be scrubbed to make sure the fields have the proper names. * They also are scrubbed of any uncessary data decided by you or the system * * @since 1.0.0 * @param string$fields           The array of field names and corresponding properties set for validation
* @param    boolean       $lead the array of lead data that was sent from the client code. * @return array$data             the scrubed array of lead data.
*/
protected function scrubArray($fields,$lead){
foreach($lead as$key => $value){ //if the keys match and the field is the correct size if( array_key_exists($key, $fields) && ( strlen($value) >= $fields[$key]['min'] && strlen($value) <=$fields[$key]['max'] ) ): if($fields[$key]['type'] == 'string' && is_string($value)){
$data[$key] = $value; } if($fields[$key]['type'] == 'phone' ){$data[$key] = preg_replace("/[^0-9]/", "",$value);
}
if($fields[$key]['type'] == 'int' && is_numeric($value)){$data[$key] =$value;
}
endif; //end keys match if
}
return $data; } //static function because authentication won't change protected static function authenticateMe(){ // Import the WSDL and authenticate the user.-----------------------------$wsdl_five9 = "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl&user=" . self::$username ; //try to authenticate with five9 try{$soap_options = array( 'login'    =>  self::$username, 'password' => self::$password,
'trace' => true );
$client_five9 = new SoapClient($wsdl_five9 , $soap_options );$response['success'] = $client_five9; }//if errors occur add the message to the response array catch (Exception$e){
$error_message =$e->getMessage();
$response['error'] =$error_message;
}
return $response; } //send the record to five9 function addRecordToList($lead, $list ){ //the conctructed array$data = $this->scrubArray( self::$fields, $lead ); //if the fields sent are all correct both arrays are the same size if(sizeof($lead) === sizeof($data) ){$client_five9 = self::authenticateMe();
if( array_key_exists('success', $client_five9) ){ //get the Soap Object$client = $client_five9['success']; //map the fields to five9 with the new ordered array$mappedFields = $this->mapFields($data, self::$fields, 1); //if the member_id is also included then send it to the memebers list if (array_key_exists("member_id" ,$data)){
$list = "members-oep"; } //the mapped fields column number must match the index of the record //therefore we must make the associated array and indexed one$data = array_values($data); //settings required by five9$listUpdateSettings["fieldsMapping"] = $mappedFields;$listUpdateSettings["skipHeaderLine"] = false;
$listUpdateSettings["cleanListBeforeUpdate"] = false;$listUpdateSettings["crmAddMode"] = 'ADD_NEW';
$listUpdateSettings["crmUpdateMode"] = 'UPDATE_SOLE_MATCHES';$listUpdateSettings["listAddMode"] = 'ADD_IF_SOLE_CRM_MATCH';
//prepare the query used to add the record to five9
$query = array ( 'listName' => "$list",
'listUpdateSettings' => $listUpdateSettings, 'record' =>$data );
//try to add the record the five9 system
try{
//get the result from running the query
//this will return an object
$result =$client->AddRecordToList($query); //get the array of variables within the results object$resp = get_object_vars($result->return); //if there was an error adding the record if($resp['failureMessage'] != ""){
$response['errors'] =$resp['failureMessage'];
}
//if it was successful either adding or updating
if($resp['crmRecordsUpdated'] == 1 ||$resp['crmRecordsInserted'] == 1){
$response['success'] = true; } }//adding failed respond with error catch (Exception$e){
//get the error message
$error_message =$e->getMessage();
//add the error message to the response array
$response['error'] =$error_message;
}
}//end arraykey if
}//end sizeof if
else{
//return the differences in the arrays usually caused due to improper names
$response["errors"] = array_diff($lead, $data); } return$response;
}//end function
//more to come
}

//more to come
protected function createList(){
}
}
?>

• @Orlando P. Please read How do I write a good answer?: "Every answer must make at least one insightful observation about the code in the question." However, this post is merely an update of the code. It would be advisable to edit the question and add the updated code. – Sᴀᴍ Onᴇᴌᴀ Nov 16 '17 at 0:42

# Feedback

The class looks like it is organized well for the most part- the methods generally handle a single task. However, some of those methods are a bit lengthy so could be broken up into smaller sub-methods. The updated code posted in the answer has methods with shorter lengths, except for the principle method addRecordToList().

In the original code there is a variable $listUpdateSettings outside the class. Was that just left over from debugging or other code? # Suggestions Below are some options for cleaning up the code and possibly making it more sustainable as the number of fields supported grows. ## Instance variables instead of passing parameters around Because you are defining a class, why not take advantage of instance variables? $data and mappedFields can both be declared as arrays. Unless they need to be access outside the code within the class, set the scope to private (or protected if a sub-class needed to utilize them).

class five9{

private $data = array(); private$mappedFields = array();

Then just reference those variables when needed:

function MapField($index,$field, $key){ //map the field to the five9 system$this->mappedFields[] =  array( "columnNumber" => $index + 1, "fieldName" =>$field, "key" => $key ); } .... function SendtoFive9($lead){

//the conctructed array
$this->ScrubArray($lead);
if(sizeof($lead) === sizeof($this->data) ){

...
$listUpdateSettings["fieldsMapping"] =$this->mappedFields;

## Validating data in ScrubArray()

There are various options for shortening the code in ScrubArray(). Two such options are outlined below, though other options are possible as well. The first approach aims for the fewest number of lines of code (while possibly sacrificing speed), while the second breaks the existing validation out into separate methods and calls them dynamically.

### Validation with Regular expressions for all fields

One option is to define regular expressions for each field that needs to be validated. Bear in mind that performing a regular expression match on a string just to check the length will typically be slower than using strlen() but this way you can look for validation rules and ensure the values match the format.

In the code below, the ReflectionClass is used to look up the constants in the class definition and if found, will use preg_match() to ensure the values conform to the field's validation rules. You could also look into using filter_var() with FILTER_VALIDATE_REGEXP

const VALIDATION_FIRST_NAME = '#^.{3,}$#'; const VALIDATION_LAST_NAME = '#^.{3,}$#';
const VALIDATION_STATE = '#^\w{0,2}$#'; const VALIDATION_ZIP = '#^\d{5}$#';
const VALIDATION_MEMBER_ID = '#^\d+$#'; const SANITAION_NUMBER1 = '#[^\d]#'; const SANITAION_NUMBER2 = '#[^\d]#'; function ScrubArray($lead){
$fields = array('first_name', 'last_name', 'number1', 'number2', 'state', 'zip', 'member_id');$reflection = new ReflectionClass($this);$constants = $reflection->getConstants(); foreach(array_keys($lead) as $index =>$field) {
if (in_array($field,$fields)) {
$constantKey = 'VALIDATION_'.strtoupper($field);
$value =$lead[$field];$key = ($field == 'number1'); //@TODO: decide with constant, method, etc. if (!$constants[$constantKey] || preg_match($constants[$constantKey],$value)) {
$this->MapField($index, $field,$key);
$sanitationKey = 'SANITATION_'.strtoupper($field);
if ($constants[$sanitationKey]) {
$value = preg_replace($sanitationKey, '', $value); }$this->data[] = $value; } } } }  ### Validation with separate methods To keep the string length validation using strlen(), you could define separate methods and call those for each field. For example, the first_name and last_name fields could both be validated by the same method: /** * Validate that a name field has more than 3 characters * @return string | bool */ function validateNameField($value) {
if (strlen($value) > 3) { return$value;
}
return false;
}

And similarly for the other fields:

/**
* Validate a number field - merely removes any non-numeric characters
* @return string
*/
function validateNumberField($value) { return preg_replace("/[^0-9]/", "",$value);
}
/**
* Validate that a statefield has no more than 2 characters
* @return string | bool
*/
function validateStateField($value) { if (strlen($value) <= 2) {
return $value; } return false; } /** * Validate that a ZIP field has exactly 5 characters * @return string | bool */ function validateZipField($value) {
if (strlen($value) == 5) { return$value;
}
return false;
}
/**
* Validate that a member ID field is numeric
* @return string | bool
*/
function validateMemberIdField($value) { if (is_numeric($value)) {
return $value; } return false; }  Then those methods could be mapped to the field names, perhaps in a helper method: function getFieldValidationMethodMapping() { return array( 'first_name' => 'validateNameField', 'last_name' => 'validateNameField', 'number1' => 'validateNumberField', 'number2' => 'validateNumberField', 'state' => 'validateStateField', 'zip' => 'validateZipField', 'member_id' => 'validateMemberIdField' ); }  Then the ScrubArray method can look up the method names based on the field name and call them dynamically: function ScrubArray($lead){
$fieldMapping =$this->getFieldValidationMethodMapping();
foreach(array_keys($lead) as$index => $field) { if (array_key_exists($field, $fieldMapping)); if (method_exists($this, $fieldMapping[$field])) {
$validationValue =$this->{$fieldMapping[$field]}($lead[$field]);
if ($validationValue !== false) {$key = ($field == 'number1'); //@TODO: decide with constant, method, etc.$this->MapField($index,$field, $key);$this->data[] = $validationValue; } } } }  ## Unit Test Perhaps you already have a unit test, but if not (or even if you do), you might find this unit test useful. Note that in my testing I actually made those instance variables $data and $mappedFields public for ease in testing, but if you take my advice above to make those fields private then you may want to make methods to get the values in those instances variables, since outside code could not directly access them. ### Update You posted your updated code and asked for it to be reviewed. I think it looks pretty good. My only suggestion is to remove the formal parameter $i from the method mapFields(), since it is only called in one place with the value 1. That value can be assigned to 1 at the start of the method, and then incremented using the post-increment operator whenever after it is used:

protected function mapFields($record,$fields){
$i = 1; foreach ($record as $key =>$value) {
//map the field to the five9 system
$mappedFields[] = array( "columnNumber" =>$i++, "fieldName" => $key, "key" =>$fields[$key]['is_key'] ); } return$mappedFields;
}

If you wanted to avoid the possible undefined variable $mappedFields you could check to make sure count($mappedFields) > 0 evaluates to true.

### Second Update

Perhaps this is too meta but it isn't obvious to me why this post deserves a downvote. While I understand that there is supposed to be some level of anonymity on these sites, I would really appreciate feedback on what reason(s) exist that caused this to get a downvote and what could be changed to reverse that action. Help not only yourself and me get our points back but also our community by improving this content!

• Hey I actually rewrote this further and put it on github, I had forgotten to update it on here. I will review your answer and incorporate some of the tips github.com/opolanco23/PHP-Five9-API/blob/master/… – Orlando P. Oct 7 '17 at 23:56
• Cool - I expanded my answer, providing another approach to re-writing the ScrubArray() method – Sᴀᴍ Onᴇᴌᴀ Oct 9 '17 at 20:44
• awesome explanation. Thanks for the input really appreciate it. If you could review the updated answer for any improvements I would also I appreciate it. – Orlando P. Oct 10 '17 at 13:30
• Whoever downvoted: Was it downvoted because the original question "I would like some input on the class and how to make it faster and allow to sendtoFive9 function to be looped without overriding the array." wasn't addressed properly (in your opinion)? – Sᴀᴍ Onᴇᴌᴀ Nov 16 '17 at 18:02


text:
## P.nut1996 What is the slope of the line which passes through (2, 6) and (0, 2)? one year ago one year ago

1. P.nut1996

A. 2 B. -3 C. 4 D. -2

2. azolotor

Slope equals the change in y over the change in x so (2-6)/(0-2)=-4/-2 = 2

3. JonathanJ

Remember, slope is $(y2-y1)\(x2-x1)$ Simply plug in your numbers, $(2-6)/(0-2)$ $(-4)/(-2)$ which is equal to 2.

4. P.nut1996

2 was my answer :) I was hoping i was right! Thanks guys

ok this is simple. Remember the formula for slope$m = \frac{ y _{1}-y _{2} }{ x _{1}-x _{2} }$

dang you win jon you win

7. P.nut1996

Yes! I forgot the formula at a very bad time. I was guessing 2:)


text:
# ATLAS Preprints

2014-09-19
00:47
 Search for pair and single production of new heavy quarks that decay to a $Z$ boson and a third-generation quark in $pp$ collisions at $\sqrt{s}=8$ TeV with the ATLAS detector A search is presented for the production of new heavy quarks that decay to a $Z$ boson and a third-generation Standard Model quark. [...] CERN-PH-EP-2014-188. - 2014. Fulltext - Previous draft version

2014-09-19
00:31
 Search for non-pointing and delayed photons in the diphoton and missing transverse momentum final state in 8 TeV $pp$ collisions at the LHC using the ATLAS detector A search has been performed, using the full 20.3 fb$^{-1}$ data sample of 8 TeV proton--proton collisions collected in 2012 with the ATLAS detector at the LHC, for photons originating from a displaced vertex due to the decay of a neutral long-lived particle into a photon and an invisible particle. [...] CERN-PH-EP-2014-215. - 2014. Fulltext - Previous draft version

2014-09-11
15:21
 Measurement of distributions sensitive to the underlying event in inclusive Z-boson production in $pp$ collisions at $\sqrt{s}=7$ TeV with the ATLAS detector / ATLAS Collaboration A measurement of charged-particle distributions sensitive to the properties of the underlying event is presented for an inclusive sample of events containing a Z-boson , decaying to an electron or muon pair. [...] CERN-PH-EP-2014-162 ; arXiv:1409.3433. - 2014. - 34 p. Previous draft version - Full text - Full text

2014-09-09
20:56
 Search for $H \rightarrow \gamma\gamma$ produced in association with top quarks and constraints on the Yukawa coupling between the top quark and the Higgs boson using data taken at 7 TeV and 8 TeV with the ATLAS detector / ATLAS Collaboration A search is performed for Higgs bosons produced in association with top quarks using the diphoton decay mode of the Higgs boson. [...] CERN-PH-EP-2014-179 ; arXiv:1409.3122. - 2014. - 12 p. Previous draft version - Full text - Full text

2014-09-05
14:23
 Measurement of long-range pseudorapidity correlations and azimuthal harmonics in $\sqrt{s_{\mathrm{NN}}}$=5.02 TeV proton-lead collisions with the ATLAS detector / ATLAS Collaboration Measurements of two-particle correlation functions and the first five azimuthal harmonics, $v_1$ to $v_5$, are presented, using 28 $\mathrm{nb}^{-1}$ of $p$+Pb collisions at a nucleon-nucleon center-of-mass energy of $\sqrt{s_{\mathrm{NN}}}=5.02$ TeV measured with the ATLAS detector at the LHC. [...] CERN-PH-EP-2014-201 ; arXiv:1409.1792. - 2014. - 21 p. Previous draft version - Full text - Full text

2014-09-05
11:10
 Electroweak production of $Z$jj and $W^{\pm}W^{\pm}$jj states at the LHC / Pagan Griso, S (LBL, Berkeley) Measurements of fiducial cross sections for the electroweak production of two jets in association with a $Z$ boson and in association with a pair of same-electric-charge $W$ bosons are presented. [...] ATL-PHYS-PROC-2014-115 ; arXiv:1409.2337. - 2014. - 6 p. Original Communication (restricted to ATLAS) - Full text - Preprint

2014-09-02
18:24
 Measurement of the top-quark mass in the fully hadronic decay channel from ATLAS data at $\sqrt{s}=7$ TeV / ATLAS Collaboration The mass of the top quark is measured in a data set corresponding to 4.6 fb$^{−1}$ of proton--proton collisions with centre-of-mass energy $\sqrt{s}=7$ TeV collected by the ATLAS detector at the LHC. [...] CERN-PH-EP-2014-208 ; arXiv:1409.0832. - 2014. - 14 p. Previous draft version - Full text - Full text

2014-09-02
15:43
 Search for long-lived neutral particles decaying into lepton jets in proton--proton collisions at $\sqrt{s}$ = 8 TeV with the ATLAS detector / ATLAS Collaboration Several models of physics beyond the Standard Model predict neutral particles that decay into final states consisting of collimated jets of light leptons and hadrons (so-called "lepton jets"). [...] CERN-PH-EP-2014-209 ; arXiv:1409.0746. - 2014. - 30 p. Previous draft version - Full text - Full text

2014-09-02
07:24
 Reconstruction and identification of hadronic decays of tau leptons in ATLAS / Zinonos, Zinonas (Gottingen U.) Hadronically decaying tau leptons are of prime importance in numerous physics analyses in ATLAS. [...] arXiv:1409.0343. - 2014. - 5 p. Preprint

2014-09-02
07:24
 Jet Charge with the ATLAS Detector using $\sqrt{s}=8$ TeV $pp$ Collision Data / Nachman, Benjamin (SLAC) The momentum-weighted sum of the charges of tracks associated to a jet provides an experimental handle on the electric charge of fundamental strongly-interacting particles. [...] arXiv:1409.0318. - 2014. Preprint


text:
Browse Questions

# A bill of Rs. 84,150 is drawn on 22nd April,2002 at 11 months and is discounted on 11th january 2003.Find the banker's gain if the rate of interest is 10%.

This question has multiple parts. Therefore each part has been answered as a separate question on Clay6.com


text:
# Windows IoT

• Hi.
Can applications developed on Windows 10 with Qt run on windows 10 IoT?

• Yes,
this is what Qt for WinRT/ UWP is meant for. The terminology can be confusing sometimes, as Microsoft changed the name from Windows Runtime to WinRT to universal Windows Platform. However, Windows 10 IoT (Core) is part of the UWP family.

If you cross compile Qt for winrt-arm-msvc2017, then the binaries will work for Win10 IoT. We also provide binary packages for those.

Please note, that Qt Creator is not able to handle deployment and debugging on remote devices due to the communication protocol being proprietrary. Hence you will need to use Visual Studio (qmake -tp vc <your-project.pro>


text:
# Details about Lab 3

The dead load (load of the structure) and the live load (us sitting in the lab) in the Bainer Hall (or any civil engineering building structure) is transmitted from the roof slab to the beams, then from the beams to the columns and finally to the foundation system via the columns. Columns are vertical members which carry the load axially through compression. Under earthquake and wind load, they can be designed to carry a component of the lateral forces. Greeks, Romans and many other old civilizations viewed columns as a symbol of strength and used columns as decorative members in front of their palaces.

Look at our UC Davis MU photos and see if you can spot the big cylindrical columns supporting the MU at https://www.ucdavis.edu/news/photos-inside-new-memorial-union/

Depending on the Length to Width ratio (slenderness ratio), the columns (and this lab) is divided into two sections:

## 1. Long columns

These columns usually fail under buckling. Read about it here.

For this lab, we looked at the primarily three different end condition.

1. Fixed, with no translation : Where no rotation and no translation is allowed. The end is screwed in and has a rubber stopper to stop it from moving.
2. Fixed, with translation : Where no rotation but translation is allowed. The end is screwed in and has a slot inwhich the whole end could move.
3. Pinned, with no translation : Where rotation but no translation is allowed. THe end has a ‘V’ notch and hasbeen screwed or a rubber stopper is used to stop it from moving.

Based on these three end conditions, we tested four different combinations of end conditions. First, we calculated the theoretical buckling force and then we applied the load experimentally to check it.

### What do I want in the report?

1. Sample calculation for your respective column:
1. Group a - Column a
2. Group b - Column b
3. Group c - Column c
2. In results:
1. Make a table of experimental and theoretical buckling forces for all columns
2. Make a table of end conditions as given at the end of the procedure in your lab manual
3. In attachments:
1. Attach a before and after photo of buckling, make sure every column is in one frame. Do not attach bubkling photo of each column separately.

## 2. Short columns

Short columns usually fail due to excessive stresses in the material. To define the failure stresses for a material/body there are many classical failure theories. You can read about failure theories here

### What do I want in the report?

We will use the table presented at the end of lab 3 in the lab manual.

1. Sample Calculation:
1. Pick a load (P (N), say 267 N), and calculate:
1. Principal normal stresses $\sigma_1$ and $\sigma_2$
2. Tresca’s failure stress $\sigma_T$
3. Von Mises failure stress $\sigma_M$
2. In results:
1. Copy the table and add columns for:
1. Principal normal stresses $\sigma_1$ and $\sigma_2$
2. Tresca’s failure stress $\sigma_T$
3. Von Mises failure stress $\sigma_M$
3. In attachements:
1. Graph for Principal normal stresses $\sigma_1$ and $\sigma_2$ vs load (P)
2. Graph for Tresca’s failure stress $\sigma_T$ and Von Mises failure stress $\sigma_M$ vs load (P)
Previous


text:
# Scenery Images of Amazing The Mountains Of Northern Croatia

This is so and so amazing indeed at the mountains of Northern Croatia after heavy snowfall. This event was happened at last week and there was a heavy snowfall located in the mountains of northern Croatia. That is, it was almost half a meter of snow that fell down in just a matter of hours. In addition, as soon as the snow clouds were gone, Zoran Stanko quickly managed to get the highest peak of Croatian Zagorje (i.e. Ivanščica 1061 meters high) and to document and photograph freshly made snow kingdom. In short, there may hope all of us may like it. More reading. More info: Facebook

Image Source: Zoran Stanko

Image Source: Zoran Stanko

Image Source: Zoran Stanko

Image Source: Zoran Stanko

Image Source: Zoran Stanko

Image Source: Zoran Stanko

Image Source: Zoran Stanko

Image Source: Zoran Stanko


text:
# This Week in Logic at CUNY

This Week in Logic at CUNY:

– – – – Monday, Nov 7, 2011 – – – –

– – – – Tuesday, Nov 8, 2011 – – – –

Computational Logic Seminar
Room 3309. Time 2:00 – 4:00 PM
Tuesday, November 8.
Speaker: Andre Rodin
Title: Doing and Showing

Abstract: The persisting gap between the formal and the informal mathematics is due
to an inadequate notion of mathematical theory behind the current formalization techniques. I mean the (informal) notion of axiomatic theory according to which a mathematical theory consists of a set of axioms and further theorems deduced from these axioms according to certain rules of logical inference. Thus the usual notion of axiomatic method is inadequate and needs a replacement.

– – – – Wednesday, Nov 09, 2011 – – – –

– – – – Thursday, Nov 10, 2011 – – – –

– – – – Friday, Nov 11, 2011 – – – –

Set Theory Seminar
Friday, November 11, 2011 10:00 am GC 6417
Professor Thomas Johnstone (NYC College of Technology (CUNY)) What is ZFC set theory when the power set axiom is removed?

Abstract. When prompted, many set theorists offer the following list of axioms: extensionality, pairing, union, infinity, separation, foundation, replacement and choice. In this talk we will prove that this formulation of set theory without power set is weaker than commonly supposed, and it is inadequate to prove several basic facts often desired in its context. For example, infinite successor cardinals can be singular, Los’ ultrapower theorem can fail, Gaifman’s theorem can fail (i.e. cofinal Sigma_1-elementary embeddings need not be fully elementary), and Sigma_1-formulas need not be closed under bounded quantification. Nevertheless, these deficits are completely repaired if one uses collection, rather replacement in the
axiomatization above. This is joint work between Joel Hamkins, Victoria Gitman and myself, and a pre-print is available at
http://arxiv.org/abs/1110.2430.

Model Theory Seminar
Friday, November 11, 2011 12:30 pm GC 6417
Professor Alfred Dolich (Kingsborough Community College)
Integer parts of real closed fields

Logic Workshop
Friday, November 11, 2011 2:00 pm GC 6417
Professor Samson Abramsky (Oxford University)
Independence in Quantum Foundations and Social Choice

Logic and Games Seminar
Friday, November 11, 2011 4:15 pm GC, Room 4419
Professor Kit Fine (New York University)
Truthmaker Semantics for Intuitionistic Logic

Abstract. tba

Next Week in Logic at CUNY:

– – – – Monday, Nov 14, 2011 – – – –

– – – – Tuesday, Nov 15, 2011 – – – –

– – – – Wednesday, Nov 16, 2011 – – – –

– – – – Thursday, Nov 17, 2011 – – – –

– – – – Friday, Nov 18, 2011 – – – –

The New York Colloquium on Algorithms and Complexity
Friday, November 18, 2011, The Graduate Center, CUNY, Room 4102, 9:00 am to 5:30 pm

NYCAC, the New York Colloquium on Algorithms and Complexity is an annual event. Its purpose is to give the opportunity to graduate students in New York to observe talks of researchers from all areas of the theory of Algorithms and Computational Complexity. Invited Speakers include Eric Allender (Rutgers U.), Martin Fürer (Penn State U.), William Gasarch (U. Maryland), George Karakostas (McMaster U.), Michael Lampis (KTH), Aris Tentes (NYU), Christos Tzamos (MIT), Vassilis Zikas (U. Maryland)

Logic Workshop
Friday, November 18, 2011 10:00 am* GC 6417
* NOTE special time
Professor Peter Koepke (Rheinische Friedrich-Wilhelms-Universität Bonn) Violating the Singular Cardinals Hypothesis without Large Cardinals

Abstract. After Easton had proved that the behavior of the exponential function 2κ at regular cardinals κ is independent of the axioms of set theory except for some simple classical laws, attention turned to the situation at singular cardinals. The Singular Cardinals Hypothesis SCH implies that the Generalized Continuum Hypothesis GCH 2κ = κ+ holds at a singular cardinal κ if GCH holds below κ. The SCH has triggered many developments in large cardinals, forcing and inner model theory. Gitik and Mitchell have determined the consistency strength of the negation of SCH in Zermelo Fraenkel set theory with the axiom of choice in terms of measurable cardinals of high Mitchell orders.

Over several years, Arthur Apter and I have pursued a program of determining such consistency strengths in Zermelo Fraenkel set theory without the axiom of choice. Often the consistency strengths become much lower than in the choiceful setting. In my talk I want to present joint work with Moti Gitik that the following is relatively consistent with Zermelo Fraenkel set theory: GCH holds below the first
uncountable limit cardinal ℵω and there is a surjection from its power set P(ℵω) onto some arbitrarily high cardinal λ. The proof uses forcing and symmetric submodels to adjoin λ subsets of ℵω that have a lot of pairwise agreement so that the GCH below ℵω is preserved.

The result lead to the conjecture that without the axiom of choice and without assuming large cardinal strength an – appropriately modified – exponential function can take rather arbitrary values at all infinite cardinals.

Note the special time! This talk begins at 10 am, and is joint between the CUNY Logic Workshop and the Set Theory Seminar. There will be a second Logic Workshop talk today at 2 pm.

Model Theory Seminar
Friday, November 18, 2011 12:30 pm GC 6417
Mr. Manuel Alves (Ph.D. Program in Mathematics, Graduate Center of CUNY) Zilber’s trichotomy

Logic Workshop
Friday, November 18, 2011 2:00 pm GC 6417
Dr. Sam Sanders (Ghent University)
Reuniting the antipodes: bringing together Nonstandard Analysis and Constructive Analysis

Abstract. Constructive Analysis was introduced by Erret Bishop to identify the computational meaning’ of mathematics. In the spirit of intuitionistic mathematics, notions like algorithm,’ explicit computation,’ and finite procedure’ are central. The exact meaning of these vague terms was left open, to ensure the compatibility of Constructive Analysis with several traditions in mathematics. Constructive Reverse Mathematics (CRM) is a spin-off of Harvey Friedman’s famous Reverse Mathematics program, based on Constructive Analysis. Bishop famously derided Nonstandard Analysis for its lack of computational meaning. In this talk, we introduce Ω-invariance’: a simple and elegant definition of finite procedure’ in (classical) Nonstandard Analysis. Using an intuitive interpretation, we obtain many results from CRM, thus showing that Ω-invariance is quite close to Bishop’s notion of `finite procedure.’

This is the second Logic Workshop talk of the day. The first, by Peter Koepke, begins at 10:00 am.

– – – – Other Logic News – – – –

– – – – Web Site – – – –

The majority of this information, including an interactive calendar of future events, can be found at our website:

http://nylogic.org/Calendar


text:
# Grid paintings à la Mondrian with JavaScript

March 04, 2017 | 9 minutes read

I was at a laundrette today and had just finished my book so I had some time to kill. Naturally I devised an algorithm for generating drawings that would resemble the grid-like paintings that Piet Mondrian made famous. With the benefit of hindsight I guess I could indulge in saner activities while waiting for my laundry to dry!

I went through different ideas but in the end I settled on a recursive approach. My idea is to divide a rectangle into two smaller ones and then to do the same with each sub-rectangle. Every time a rectangle is generated and is then filled with a random color; like Mondrian I use yellow, red, blue, black and white.

## The work

In the end the algorithm I implemented generates images like these.

## The code

The implementation is very short. I started by defining two classes - Point and Rectangle - for the sake of tidiness.

A rectangle is thus defined by an upper left point - called min - and a lower right point - called max. Here is an image just to make things clear.

The next step is to be able to draw a rectangle. The CanvasRenderingContext2D has a strokeRect(x1, y1, x2, y2) method but I had already written something before I knew this; anyway it isn’t very complicated. I attached the method to the Rectangle class.

I simply go around each corner of the rectangle in a clockwise fashion, starting at the top-left corner.

Kid’s stuff! Now comes the interesting part. The next step is to split a rectangle in two; there are two pitfalls to handle:

1. A rectangle can be half in two ways, either left/right or either top/bottom.
2. A split can produce rectangles which are too narrow and not visually appealing.

To handle the first pitfall, I split the rectangle into a left and a right rectangle if the rectangle’s width is greater than it’s height and vice-versa. To generate two sub-rectangles, I simply choose a random point along the $x$-axis in case of a left/right split or along $y$-axis in case of a top/bottom split.

To handle the second pitfall, I defined some padding numbers so that the points I generated were not too close to the current rectangle’s edges. The code for splitting a rectangle goes as follows:

It takes some time to get the point juggling right but all in all it’s pretty easy; the following illustration might help.

The randInt function simply generates an integer in the $[a, b)$ range, here is it’s definition:

As I mentioned the algorithm has to be recursive. This is easy to do, we only have to call the split method on each sub-rectangle. However the issue is to know when to stop. To fix this I simply introduced a depth parameter in the call to the split method; if the current depth is higher than a fixed limit then the recursion stops. Moreover, if a rectangle is too small - i.e. it not wide enough or not tall enough - then the recursion also stops. Finally I added the contouring and the filling of the rectangles into the split method. All in all the code is the following:

The colors variable has more whites so that the white color appears more often on the resulting image. To run the code with a canvas we simply have to obtain the canvas’s dimensions, create a rectangle from these dimensions and then call the split method on this initial rectangle.

That’s all there is to it! The full code is available on GitHub. I hope you enjoyed the read!


text:
#### 12th Standard Chemistry English Medium Reduced Syllabus Model Question paper With Answer Key -2021 Part - 2

12th Standard

Reg.No. :
•
•
•
•
•
•

Chemistry

Time : 02:45:00 Hrs
Total Marks : 70

Part I

Answer all the questions.

Choose the most suitable answer from the given four alternatives and write the option code with the corresponding answer.

15 x 1 = 15
1. The metal oxide which cannot be reduced to metal by carbon is

(a)

PbO

(b)

AL2O3

(c)

ZnO

(d)

Feo

2. Which of the following is used for concentrating ore in metallurgy?

(a)

Leaching

(b)

Roasting

(c)

Froth floatation

(d)

Both (a) and (c)

3. The geometry at which carbon atom in diamond are bonded to each other is

(a)

Tetrahedral

(b)

graphene

(c)

Fullerene

(d)

dry ice

4. Among the following, which is the strongest oxidizing agent?

(a)

Cl2

(b)

F2

(c)

Br2

(d)

l2

5. The magnetic moment of Mn2+ ion is

(a)

5.92BM

(b)

2.80BM

(c)

8.95BM

(d)

3.90BM

6. Which one of the following statements related to lanthanons is incorrect?

(a)

Europium shows +2 oxidation state

(b)

The basicity decreases as the ionic radius decreases from Pr to Lu.

(c)

All the lanthanons are much more reactive than aluminium

(d)

Ce4+ solutions are widely used as oxidising agents in volumetric analysis.

7. As per IUPAC guidelines, the name of the complex [Co(en)2(ONO)Cl]Cl is

(a)

chlorobisethylenediaminenitritocobalt(III) chloride

(b)

chloridobis(ethane-1,2-diamine)nitro  K-Ocobaltate(III) chloride

(c)

chloridobis(ethane-1,2-diammine)nitrito K-Ocobalt(II) chloridde

(d)

chloridobis(ethane-1,2-diamine)nitro K-Ocobalt(III) chloride

8. Choose the correct statement

(a)

Square planar complexes are more stable than octahedral complexes

(b)

The spin only magnetic moment of [Cu(Cl)4]2- is BM and it has square planar structure.

(c)

Crystal field splitting energy $\left( { \Delta }_{ 0 } \right)$ [FeF6]4- is higher than the $(\Delta _{ 0 })$ $[Fe(CN)6]{ { 4 }^{ - } }$

(d)

crystal field stabilization energy of [V(H2O)6]2+ is higher than the crystal field stabilization of [Ti(H2O)6]2+

9.  if ‘a’ stands for the edge length of the cubic system ; sc , bcc, and fcc. Then the ratio of radii of spheres in these systems will be respectively

(a)

$\left( \cfrac { 1 }{ 2 } a;\cfrac { \sqrt { 3 } }{ 2 } a;\cfrac { \sqrt { 2 } }{ 2 } a \right)$

(b)

$\left( \sqrt { 1a } :\sqrt { 3a } :\sqrt { 2a } \right)$

(c)

$\left( \cfrac { 1 }{ 2 } a:\cfrac { \sqrt { 3 } }{ 4 } a:\cfrac { 1 }{ 2\sqrt { 2 } } a \right)$

(d)

$\cfrac { 1 }{ 2 } a:\sqrt { 3 } a:\cfrac { 1 }{ \sqrt { 2 } } a$

10. The correct difference between first and second order reactions is that (NEET)

(a)

A first order reaction can be catalysed; a second order reaction cannot be catalysed.

(b)

The half life of a first order reaction does not depend on [A0]; the half life of a second order reaction does depend on [A0].

(c)

The rate of a first order reaction does not depend on reactant concentrations; the rate of a second order reaction does depend on reactant concentrations.

(d)

The rate of a first order reaction does depend on reactant concentrations; the rate of a second order reaction does not depend on reactant concentrations.

11. Statement :
To stop bleeding from an injury, ferric chloride can be applied. Which comment about the statement is justified?

(a)

It is not true, ferric chloride is a poison.

(b)

It is true, Fe3+ ions coagulate blood which is a negatively charged sol

(c)

It is not true; ferric chloride is ionic and gets into the blood stream.

(d)

It is true, coagulation takes place because of formation of negatively charged sol with Cl-.

12. Assertion : Phenol is more reactive than benzene towards electrophilic substitution reaction
Reason : In the case of phenol, the intermediate arenium ion is more stabilized by resonance
Codes:
(a) if both assertion and reason are true and reason is the correct explanation of assertion.
(b) if both assertion and reason are true but reason is not the correct explanation of assertion.
(c) assertion is true but reason is false
(d) both assertion and reason are false.

(a)

if both assertion and reason are true and reason is the correct explanation of assertion.

(b)

if both assertion and reason are true but reason is not the correct explanation of assertion.

(c)

assertion is true but reason is false

(d)

both assertion and reason are false.

13. Which one of the following reduces tollens reagent

(a)

formic acid

(b)

acetic acid

(c)

benzophenone

(d)

none of these

14. CH3CH2 Br $\overset { aqNaOH }{ \underset { \Delta }{ \longrightarrow } } A\overset { { KMnO }_{ 4 }{ /H }^{ + } }{ \underset { \Delta }{ \longrightarrow } } B\overset { { NH }_{ 3 } }{ \underset { \Delta }{ \longrightarrow } } C\overset { { Br }_{ 2 }/NaOH }{ \longrightarrow } D \ D'is$

(a)

bromomethane

(b)

$\alpha$-bromo sodium acetate

(c)

methanamine

(d)

acetamide

15. Among the following, the reaction that proceeds through an electrophilic substitution, is :

(a)

(b)

(c)

(d)

1. Part II

Answer any 6 questions. Question no. 24 is compulsory.

9 x 2 = 18
16. What is passivation?

17. What are limitations of Freundlich adsorption isotherm?

18. ${ C }_{ 6 }{ H }_{ 5 }{ NH }_{ 2 }\xrightarrow [ 273k,HCl ]{ { HNO }_{ 2 } } A\xrightarrow [ { Cu }_{ 2 }({ CN })_{ 2 } ]{ KCN } B\underrightarrow { { H }_{ 3 }O } C$
Identify A, Band C.

19. Aniline reacts with bromine water to give a white precipitate.
(i) Give the chemical formula of the white precipitate formed in the above reaction.
(ii) Write the chemical reaction involved

20. Identify whether the following compounds are D or L isomers.

21. What are epimers?

22. A child is diagnosed with bleeding gums, is likely to have the deficiency of which vitamin?

23. Name the substance used as an antiseptic as well as disinfectant.

24. Explain the action of morphine as a pain killer.

1. Part III

Answer any 6 questions. Question no. 33 is compulsory.

9 x 3 = 27
25. Give one example for each of the following
(i) icosogens
(ii) tetragen
(iii) prictogen
(iv) chalcogen

26. Write the reason for the anamolous behaviour of Nitrogen.

27. Identify the order for the following reactions
(i) Rusting of Iron
(ii) Radioactive disintegration of 92U238
(iii) $2A+3B\longrightarrow products$;rate k[A]1/2[B]2

28. Why is AC current used instead of DC in measuring the electrolytic conductance?

29. Derive the relation between EMF and free energy.

30. Account for the following:
(a) Lower members of alcohols are soluble in water but higher members are not.
(b) Alcohols cannot be used as solvent for Grignard reagent.

31. What is the action of HCN on
(i) propanone
(ii) 2,4-dichlorobenzaldehyde.
(iii) ethanal

32. Write a note on
(i) Perkin's reaction, and
(ii) Knoevenagal reaction.

33. Distinguish between fat soluble and water soluble vitamins.

1. Part IV

Answer all the questions.

10 x 5 = 50
34. The selection of reducing agent depends on the thermodynamic factor: Explain with an example.

35. List the applications of iron

36. Deduce the oxidation number of oxygen in hypofluorous acid – HOF.

37. Write a short note on the oxidation states of 3d series elements.

38. The time for half change in a first order decomposition of a substance A is 60 seconds. Calculate the rate constant. How much of A will be left after 180 seconds?

39. The specific reaction. rates of a chemical reaction are 2.45 x 10-5 sec-1 at 273 K and 16.2 x10-4 sec-1 at 303 K. Calculate the activation energy.

40. Write a note on sacrificial protection.

41. Write all possible isomers with molecular formula C4H10O and name them.

42. Write the crossed aldol condensation.

43. Identify A,B and C
$\overset{SoCl_2}\longrightarrow A \overset{NH_3}\longrightarrow B\overset{LiAH_4}\longrightarrow (C)$


text:
# Remove All Nodes Which Don't Lie in Any Path With Sum>=k using C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

Best Seller

66 Lectures 5.5 hours

In this problem, we have a binary tree with a path from the root node to the leaf node that is completely defined. The sum of all nodes from a root node to a leaf node must be greater than or equal to k. So we need to remove all nodes in the paths whose sum is less than k. An important thing to remember here is that a node may be a part of many paths, so only remove such nodes if all the paths have sum < k.

From the root node to the leaf node, we can calculate the sum. When the recursive call completes for a node and control returns, we can check if the sum is < k for both left and right paths. If the sum is less than k for both the left and right paths, we need to remove this node.

Let's suppose we have 150 K and a tree like this −

      10
/ \
20 30
/ \  / \
5 35 40 45
/ \ / \
50 55 60 65
/ \    / /
70 80 90 100

If we see that the path root->left->left has a sum of 10 + 20 + 5, which is 25, less than 150, we need to prune it and remove 5. After this, let's evaluate 10->30->40. It's less than 150, so remove 40. Now we see another path 10->20->35->50 and the total sum 115 which is less than 150, so we remove 50. Now we have left paths are

10->20->35->55->70 ;
10->20->35->55->80 ;
10->30->45->60->90 ;
10->30->45->65->100 ;

The sum of all paths is greater than 150, so we don't need to prune anymore.

## Example

#include <iostream>
using namespace std;
class Node {
public:
int value;
Node *left, *right;
Node(int value) {
this->value = value;
left = right = NULL;
}
};
Node* removeNodesWithPathSumLessThanK(Node* root, int k, int& sum) {
if(root == NULL) return NULL;
int leftSum, rightSum;
leftSum = rightSum = sum + root->value;
root->left = removeNodesWithPathSumLessThanK(root->left, k, leftSum);
root->right = removeNodesWithPathSumLessThanK(root->right, k, rightSum);
sum = max(leftSum, rightSum);
if(sum < k) {
free(root);
root = NULL;
}
return root;
}
void printInorderTree(Node* root) {
if(root) {
printInorderTree(root->left);
cout << root->value << " ";
printInorderTree(root->right);
}
}
int main() {
int k = 150;
Node* root = new Node(10);
root->left = new Node(20);
root->right = new Node(30);
root->left->left = new Node(5);
root->left->right = new Node(35);
root->right->left = new Node(40);
root->right->right = new Node(45);
root->left->right->left = new Node(50);
root->left->right->right = new Node(55);
root->right->right->left = new Node(60);
root->right->right->right = new Node(65);
root->left->right->right->left = new Node(70);
root->left->right->right->right = new Node(80);
root->right->right->left->left = new Node(90);
root->right->right->right->left = new Node(100);
int sum = 0;
cout << "Inorder tree before: ";
printInorderTree(root);
root = removeNodesWithPathSumLessThanK(root, k, sum);
cout << "Inorder tree after: ";
printInorderTree(root);
return 0;
}

## Output

Inorder tree before: 5 20 50 35 70 55 80 10 40 30 90 60 45 100 65
Inorder tree after: 20 35 70 55 80 10 30 90 60 45 100 65

Tree after we pruned it completely −

         10
/ \
20 30
\   \
35 45
\ / \
55  60 65
/ \  /  /
70 80 90 100

## Conclusion

As we can see that after the initial observation, we can apply the DFS and remove nodes as our recursive function returns from each call by computing the sum at that node. Overall a simple observational and methodological problem.

Updated on 18-May-2022 11:48:55


text:
# Poincaré invariance of linearly polarised plane wave

I am reading a book that just quotes the Lie group generators and the discrete subgroups that leave a linearly polarised plane wave unchanged.
And I have no idea how to derive them.

## Context

The electromagnetic field tensor $$F_{\mu\nu} = \partial A_{\mu}/\partial x_{\nu} - \partial A_{\nu}/\partial x_\mu$$ is:

$$\left ( \begin{array}{ccc} 0& E_1 & E_2 & E_3 \\ -E_1 & 0 & H_3 & -H_2 \\ -E_2 & -H_3 & 0 & H_1 \\ -E_3 & H_2 & -H_1 & 0 \end{array} \right ),$$

and a Poincaré transformation $$g = (L|v)$$ leaves the field invariant because $$L.F.L^{T}(g^{-1}x) = F(x).$$

However the gauge potential $$A$$ is not left invariant, but gauge transformations come to the rescue: $$L.A(g^{-1}x) = A(x) + \partial \chi.$$

## Problem at hand

Now the book makes an example: a linearly polarised plane wave with wave vector $$q$$ along the $$x_2$$ axis, electric field along $$x_3$$ axis and magnetic field in the $$x_1$$ direction: $$E_3 = H_1 = A\cos(2\pi q.x) \quad \text{with} \quad q^{\mu} = (\omega, 0, \omega, 0) .$$

Then it just states:

This field has as symmetry group a Poincaré transformation with translations $$a$$ such that $$q^\mu a_\mu = 0 \,\,\text{mod}\,\,1$$, and a point group which consists of a Lie group with generators:

$$L_1(t) = \left ( \begin{array}{ccc} 1+\frac{1}{2}t^2 & \sigma & -\frac{1}{2}t^2 & 0 \\ t & 1 & -t & 0 \\ \frac{1}{2}t^2 & t & 1-\frac{1}{2}t^2 & 0 \\ 0 & 0 & 0 & 1 \end{array} \right ), \qquad L_2(t) = \left ( \begin{array}{ccc} 1+\frac{1}{2}t^2 & 0 & -\frac{1}{2}t^2 & t \\ 0 & 1 & 0 & 0 \\ \frac{1}{2}t^2 & 0 & 1-\frac{1}{2}t^2 & \rho \\ t & 0 & -t & 1 \end{array} \right ),$$ and a discrete subgroup generated by the transformations $$2_y = \left ( \begin{array}{ccc} 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{array} \right ), \quad 2_x'= \left ( \begin{array}{ccc} -1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & -1 & 0 \\ 0 & 0 & 0 & -1 \end{array} \right ), \quad m_x = \left ( \begin{array}{ccc} 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{array} \right )$$

I have $$\color{red}{\text{no idea}}$$ how the above matrices are derived.
Does anyone have an intuition on how this was done?

• Are you sure you don't have some typos? What are $\rho,\sigma$? Should they be $t$? Even if so you might have some errors in $L_2$. – Tal Sheaffer Feb 1 at 19:17
• There was a tiny typo in $L_2$, first row, you are right. Anyway I don't know what $\sigma$ and $\rho$ are supposed to be. The book just quotes them, I was hoping they were known things in the field of Lie algebras and Poincaré groups... – SuperCiocia Feb 2 at 0:25
• This is on page 45, Aperiodic Crystals by Ted Janssen – SuperCiocia Feb 2 at 0:27
• Honestly, I don't get it. I think the author may have an error. For one thing, $L F L^{\rm tr} = F$ implies $\det (L) = \pm 1$ (as is generally the case for Lorenz transformations) but from a quick calculation one sees this is only true for $\sigma = \rho = t$. However, even then the metric isn't preserved, e.g. $L_1 g L_{1}^{\rm tr} \neq g$. And neither is the chosen $F$. – Tal Sheaffer Feb 3 at 15:18


text:
# Classification of Self similar sets

I am looking at self similar sets in $\mathbb{C}$ defined as the fixed set or a sequence of contractions or an iterated function system. I am currently trying to classify these sets by how they are connected. I have come up with 3 classifications so far and think that all self similar sets fit into these categories although I have not been able to prove this fact and am looking for some help proving it or a counterexample in another category (most likely non rectifiably connected sets that are not Jordan arcs). I shall state the categories and give an example from each to give some clarification.

Non rectifiably connected Jordan arcs (Koch arc)

Rectifiably connected sets (Sierpenski Gasket)

Totally disconnected sets (C x C : a 2 dimensional cantor set)

Thank you for your help. I apologise if I have been unclear anywhere, I will try and clarify any points that need it.

-
I am given to understand that such open ended questions are not encouraged on this site. To focus it you should add more information about what you intend to use this classification for and what kinds of contractions you are interested in. That said, where would you put as set that is a Cantor set cross an interval? It is not connected but also not totally disconnected. –  BSteinhurst Oct 13 '11 at 3:30
I am not familiar with the adjective "rectifiably" so I cannot tell if your classification includes tree-like (e.g., fern pictures). You should also note that CxC is homeomorphic to C. –  Matt Brin Jan 17 '12 at 15:39