Question about drawing an spiral inductor via Skill

InvokeMeWell

Junior Member level 3
Joined
May 17, 2015
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,471
Hello,

I have been trying with chat gpt helps to draw an octagonal spiral inductor, I have successfully draw N =1 spiral inductor, but I want to expand it to 2,3 & 4 spirals.
Below is my code in python, which afterwars I "translated" in skill to draw the inductor, but for N>1 it fails the spacing is which I set e.g. 4 is not the real spacing between each spire.
Any have any ideas how to implemented?

thank you in advance
 

I can't help much but since you mention ChatGPT have you questioned ElektrodaBot based on Chat GPT 5? At Elektroda.com (it seems to welcome anyone). Might be worth a try if it understands Python and Skill. Our Edaboard administrators encouraged us to comment on its degree of expertise.
 
I will check as soon as I come today !! thanks for your comment, I don't even knew it
--- Updated ---

Perhaps not as funny or accurate as GROK, but GPT-4 does do a much better job than GPT3.5.

But why not ask for a better tool?
I want do it my self, I have found like 20+ companies who "design" an inductor, and we have of course a simulator for inducors but I want also to have a skill script which implements the inductor and afterwards simulate them.
I think the "drawing" of a sprial inductor is nothing special, thus I am asking here for help if someone could just point me where in my code I am wrong
 

I couldn't get a response from GPT-4
But 3.5 did


import turtle
import math

def draw_spiral_octagon(od, spacing, width, turns):
turtle.speed(2) # Set the drawing speed

# Calculate the radius of the octagon
radius = od / (2 * math.sqrt(2))

# Set the initial position
turtle.penup()
turtle.goto(-radius, 0)
turtle.pendown()

# Draw the spiral octagon
for turn in range(turns):
for _ in range(8):
turtle.forward(spacing)
turtle.left(45)
turtle.forward(width)
turtle.left(45)

turtle.left(360 / turns)

turtle.done()

# Example usage
outer_diameter = 200 # Adjust as needed
spacing = 10 # Adjust as needed
width = 5 # Adjust as needed
turns = 5 # Adjust as needed

draw_spiral_octagon(outer_diameter, spacing, width, turns)
 

I got a GPT-4 response

This code uses Matplotlib to plot the points of the octagon for each turn and then shows the full spiral. Adjust the wh, height, turns, and spac∈g parameters to fit the specific dimensions you require.

Remember that this code assumes that the inductor lies flat on the XY-plane and does not take into account the 3D nature of real-world inductors where the wire would have a certain thickness. Additionally, for RF applications, the precise shape, spacing, and dimensions would need to be calculated considering the inductance, Q factor, and other relevant parameters.


import numpy as np
import matplotlib.pyplot as plt
def draw_octagonal_spiral(width, height, turns, spacing):
# Initialize the center of the inductor
centerX = width / 2
centerY = height / 2
for turn in range(turns):
# Calculate the radius for this turn, accounting for the spacing
radiusX = turn * (1) * width / (2 * turns) + turn * spacing
radiusY = turn * (1) * height / (2 * turns) + turn * spacing
rotation = np.pi / 8 # 22.5 degrees for an octagon
# Initialize arrays to hold the points of the octagon
xPoints = np.zeros(9)
yPoints = np.zeros(9)
# Calculate the points of the octagon
for i in range(9):
angle = i * np.pi / 4 + rotation + turn * np.pi / 4 # Rotate each turn
xPoints = centerX + radiusX * np.cos(angle)
yPoints = centerY + radiusY * np.sin(angle)
# Plot the current turn
plt.plot(xPoints, yPoints, 'o-')
# Show the plot
plt.axis('equal')
plt.show()
# Define your parameters
width = 100
height = 100
turns = 4 # Number of turns in the spiral
spacing = 4 # Spacing between the turns
# Draw the octagonal spiral inductor
draw_octagonal_spiral(width, height, turns, spacing)



Please rate this generated program with your feedback.
 
hello thanks for your code but has the same bug as mine
I copy paste your code thus spacing should be 4, but the spacing 4 e.g. the orange is almost 63 and the red color is the maximum height is over 80+!!
 

Sunnysky wrote:
that created concentric octagon circles and not spirals, can you fix the code using python and numpy
I understand the difficulty you're facing and would like to help you draw an octagonal spiral with the proper spacing between turns. To achieve this, we need to increment the size of each octagon for each turn by a fixed amount that accounts for the spacing between the turns. We can use a loop to draw each side of the octagon, and increment the length of the sides with each turn.

Here's how you could implement this in Python using the NumPy and Matplotlib libraries:

Code: python Expand Select all Copy to clipboard

import numpy as np
import matplotlib.pyplot as plt
def draw_octagonal_spiral(num_turns, initial_radius, spacing):
# Define the number of sides for the octagon
num_sides = 8

# Create a figure and axis for the plot
fig, ax = plt.subplots()
# Initialize the starting angle and the angle step for each side
start_angle = 0
angle_step = 2 * np.pi / num_sides

# Initialize the starting point for the spiral
x, y = 0, initial_radius

for turn in range(num_turns):
for side in range(num_sides):
# Calculate the end point of the current side
x_end = x + (initial_radius + turn * spacing) * np.cos(start_angle + side * angle_step)
y_end = y + (initial_radius + turn * spacing) * np.sin(start_angle + side * angle_step)

# Draw the side
ax.plot([x, x_end], [y, y_end], color='blue')

# Update the starting point for the next side
x, y = x_end, y_end

# Update the starting angle for the next turn to make the spiral
start_angle += angle_step / num_sides

# Set equal aspect ratio
ax.set_aspect('equal', 'box')

# Set the plot limits
plot_radius = initial_radius + num_turns * spacing
ax.set_xlim([-plot_radius, plot_radius])
ax.set_ylim([-plot_radius, plot_radius])
# Show the spiral
plt.show()
# Define the number of turns, the initial radius, and the spacing
num_turns = 4
initial_radius = 10
spacing = 10
# Draw the octagonal spiral inductor
draw_octagonal_spiral(num_turns, initial_radius, spacing)

(Edit: I had to change the quote marks that invoke font jax {?} like"spacing" below , a compatability issue with GPT-4)

In this script, we have created a function 'draw_octagonal_spiral' that takes three arguments: the number of turns 'num_turns', the initial radius 'initial_radius', and the spacing between the turns `spacing`. The script calculates the position of each corner of the octagon for each turn, then plots lines between these points to create the sides of the octagon.

You can modify the 'num_turns', 'initial_radius', and 'spacing' variables to make the spiral inductor according to your specifications. This code assumes that the inductor is flat and does not account for wire thickness or other 3D aspects of a real inductor.


You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
 
Last edited:
Hi,

can you show (sketch) how you want it to look like, Just a raw example.
Is it 2D only? On one layer? (no 3D. Not multiple layers involved?)

What parameters for the calculation do you want as variables?

I can do the steps, but are not familiar with your language.

****
If I´m not mistaken one needs at least:
* center of spiral; x0, y0 (for example: 0 / 0)
* edges per rev: ed (8)
* starting radius: sr (10)
* rotation direction: rd CW / CCW (CCW)
* starting angle: sa (0°= right side of center)
* revolutions: rev (3. Should be integer, I guess)
* trace width: tw (2)
* space between traces: sp (10)
----------
Pseudo code: (not implemented: center of spiral, rotation direction)
* so one starts with angle: sa = 0
* one needs to calculate angle step size: as = 360° / ed
* one needs to calculate radius step size: rs = (tw +sp) / ed
* radius = sr;
* angle = sa;
* xs = radius * sin(angle);
* ys = radius * cos(angle);
* (startpunkt = xs, ys);
* one needs to calculate n steps: n = rev * ed; ( 3 x 8 = 24) --> "for n = 1 to 24"
{
radius =radius + rs;
angle = angle + as;
xe = radius * sin(angle);
ye = radius * cos(angle);
draw line from (xs, ys) to (xe, ye);
xs = xe;
ys = ye;
}

Klaus
 

Hello Klaus even in python it would be idea:


parameters will be the Width of the metal, spacing, number of turns here 4, the total width of the inductor and the height of the inductor (total width of the inductor and the total height of the inductor could be different!). It is octagonal inductor, one layer
 

Hi,

wow, this is not a simple spiral. It´s somehow interleaved.
And you want it like this? I did not expect this.

Klaus
 

hello again,
no this code is totally wrong.
View attachment 186736
I disagree , the only part wrong is the definition of a spiral , it does plot concentric octagons.
Now you can either program it is python or use better descriptors for GPT-4 to define what you expect.
Look at the program. The angle of element each is not 360/8 but decreased by the spacing and % diameter reduction /8 of the next loop using the starting point. Fix your program by defining the center datum point and starting point and correct angle of next octagon angle and length.
 

Cookies are required to use this site. You must accept them to continue using the site. Learn more…