diff --git a/StrangeAttractors.py b/StrangeAttractors.py index c327e6f..ab4d338 100644 --- a/StrangeAttractors.py +++ b/StrangeAttractors.py @@ -13,13 +13,14 @@ import random from textwrap import wrap + - -char = "VMMKMRMREPCPYAFRGJBOTPHNQRFXVNSNYQVJNBXXPKRPVHFQAFGFSTHYFKCIDWXOQJAKRFKHPYHNENTDQLJMQGMXTFPBDFUIPAIODWYAMTXJDIWGERTHDOKWFXPLSWFYPXNQMNOBKILSG" # "VHETJPMKNMHQNUVBIOTFADJUXXIQRSGDSNXAGNEKPMCJRIDEHOFTVTPLWUFLNDCWLKHXKKELUMBDOHSIBSDEWWSPLQVMWLQERMCANDUBCXULQWYGOTLGLLQFSJGVQEUIEQQXXWGEKVTPA" # "UBLFBKKFNATJVTJUKJFGALBIPQHVRUMAROTNVHBLAQVSHVHRGLFJAAABFRJFW" # "JJICKAFXIOXFVGOCIDNIVRPSFYPFGABXKKONQWPAMJGKAGXDBBWFHGXBTPNVD" # "EWM?MPMMWMMMM" #"EZPMSGCNFRENG" #"AXBH" +char = "EAHSVIGTJKOTB" # "^VRDSNKGRT" # "]YDUCBE" #"]SBSMKG" #"]PHXUEG" # "VMMKMRMREPCPYAFRGJBOTPHNQRFXVNSNYQVJNBXXPKRPVHFQAFGFSTHYFKCIDWXOQJAKRFKHPYHNENTDQLJMQGMXTFPBDFUIPAIODWYAMTXJDIWGERTHDOKWFXPLSWFYPXNQMNOBKILSG" # "VHETJPMKNMHQNUVBIOTFADJUXXIQRSGDSNXAGNEKPMCJRIDEHOFTVTPLWUFLNDCWLKHXKKELUMBDOHSIBSDEWWSPLQVMWLQERMCANDUBCXULQWYGOTLGLLQFSJGVQEUIEQQXXWGEKVTPA" # "UBLFBKKFNATJVTJUKJFGALBIPQHVRUMAROTNVHBLAQVSHVHRGLFJAAABFRJFW" # "JJICKAFXIOXFVGOCIDNIVRPSFYPFGABXKKONQWPAMJGKAGXDBBWFHGXBTPNVD" # "EWM?MPMMWMMMM" #"EZPMSGCNFRENG" #"AXBH" print(char) dimension = 0 type_of_attractor = None torus = False # True +planet = True if torus ==True: print("Torus from a .", end='') @@ -92,9 +93,11 @@ print("4D "+type_of_attractor+".") if char[0] == "Y" or char[0] =="Z" or char[0] =="[": dimension = 3 + type_of_attractor = "modulus" print("3D modulus map.") if char[0] =="\\"or char[0] =="]"or char[0] =="^": dimension = 3 + type_of_attractor = "trigonometrical" print("3D trigonometrical map.") @@ -102,25 +105,41 @@ run = 0 while run < stop: print ("run = ", run) - x = random.uniform(-0.1,0.1) - y = random.uniform(-0.1,0.1) - z = random.uniform(-0.1,0.1) - w = random.uniform(-0.1,0.1) + x = random.uniform(-1.,1.) + y = random.uniform(-1.,1.) + z = random.uniform(-1.,1.) + w = random.uniform(-1.,1.) + if stop > 500: + x = random.uniform(-0.1,0.1) + y = random.uniform(-0.1,0.1) + z = random.uniform(-0.1,0.1) + w = random.uniform(-0.1,0.1) + if stop > 2000: + x = random.uniform(-0.01,0.01) + y = random.uniform(-0.01,0.01) + z = random.uniform(-0.01,0.01) + w = random.uniform(-0.01,0.01) + if stop > 5000: + x = random.uniform(-0.001,0.001) + y = random.uniform(-0.001,0.001) + z = random.uniform(-0.001,0.001) + w = random.uniform(-0.001,0.001) variables = (x,y,z,w) x_vals = [] y_vals = [] z_vals = [] w_vals = [] i = 0 - n = 50000 + n = 100000 n_temp = n dt = 0.01 + variables = functions.function(char,variables,dt) while i < n_temp: variables = functions.function(char,variables,dt) - conditions = 0 + conditions = 0. if dimension >= 1: x_vals.append( variables[0]) - conditions = x_vals[i]*x_vals[i] + conditions = x_vals[i] * x_vals[i] if dimension >= 2: y_vals.append( variables[1]) conditions = conditions + y_vals[i]*y_vals[i] @@ -130,10 +149,11 @@ if dimension >= 4: w_vals.append( variables[3]) conditions = conditions + w_vals[i]*w_vals[i] - #print(x_vals[i],y_vals[i],z_vals[i]) + #print(x_vals[i],y_vals[i],z_vals[i]) + i=i+1 - if conditions > 100: + if conditions > 1.e+100 and stop < 100000: # 1.8e+308 print("conditions wasn't met because absolute value of conditions = ", conditions) n_temp = i stop = stop + 1 @@ -142,28 +162,30 @@ filename_sub = None if dimension == 2: plt.subplots(dpi = 250) - plt.scatter(x_vals, y_vals, s = 0.05, facecolors = 'blue', edgecolors = 'none') + plt.scatter(x_vals, y_vals, s = 0.1, facecolors = 'blue', edgecolors = 'none') plt.xlabel("X Axis", fontsize=8) plt.ylabel("Y Axis", fontsize=8) - filename_sub = "2D-"+type_of_attractor+"-attractor-"+char+")" + filename_sub = "2D-"+type_of_attractor+"-attractor-"+char plt.title("2D-"+type_of_attractor+" attractor: (x$_{0}$,y$_{0}$)=(%f" %x + ",%f" %y + ")") new_string = "SABOOK-Code: "+char - plt.text(0, 1.75, s="\n".join(wrap(new_string)),fontsize=5, horizontalalignment="center") + xmin, xmax, ymin, ymax = plt.axis() + print(xmin, xmax, ymin, ymax) + plt.text(xmin+(xmax-xmin)/2, ymin+(ymax-ymin)*1.11, s="\n".join(wrap(new_string)),fontsize=5, horizontalalignment="center") if dimension >= 3: fig = plt.figure(dpi = 250) ax = fig.add_subplot(1, 1, 1, projection='3d') - ax.scatter(x_vals, y_vals, z_vals, s = 0.05, facecolors = 'blue', edgecolors = 'none') + ax.scatter(x_vals, y_vals, z_vals, s = 0.1, facecolors = 'blue', edgecolors = 'none') ax.set_xlabel("X Axis", fontsize=8) ax.set_ylabel("Y Axis", fontsize=8) ax.set_zlabel("Z Axis", fontsize=8) - filename_sub = "3D-"+type_of_attractor+"-attractor-"+char+")" + filename_sub = "3D-"+type_of_attractor+"-attractor-"+char ax.set_title("3D-"+type_of_attractor+" attractor: (x$_{0}$,y$_{0}$,z$_{0}$)=(%f" %x + ",%f" %y + ",%f" %z +")") new_string = "SABOOK-Code: "+char fig.text(0.5, 0.94, s="\n".join(wrap(new_string)),fontsize=5, horizontalalignment="center") -plt.axis('square') -plt.axis('scaled') +#plt.axis('square') +#plt.axis('scaled') bad_chars = [';', ':', '!', "?", "*", " ", "*", "\\", "/", "|", "<", ">"] for i in bad_chars: diff --git a/functions.py b/functions.py index 624eba6..154e040 100644 --- a/functions.py +++ b/functions.py @@ -250,30 +250,84 @@ def function(char, oldvariables, epsilon): W = w + epsilon * W variables = (X,Y,Z,W) - """ + # Y - X = a[1] + a[2]*x + a[3]*y + a[4]|X| + a[5]|Y| - Y = a[6] + a[7]*x + a[8]*y + a[9]|X| + a[10]|Y| - Z = *np.power(x,2) + *np.power(y,2) + if char[0] == "Y": + x = oldvariables[0] + y = oldvariables[1] + z = oldvariables[2] + X = a[1] + a[2]*x + a[3]*y + a[4]*np.abs(x) + a[5]*np.abs(y) + Y = a[6] + a[7]*x + a[8]*y + a[9]*np.abs(x) + a[10]*np.abs(y) + Z = np.power(x,2) + np.power(y,2) + variables = (X,Y,Z) # Z - X = a[1] + a[2]*x + a[3]*y + a[4]*x AND a[5]*y + a[6]*x OR a[7]*y - Y = a[8] + a[9]*x + a[10]*y + a[11]*x AND a[12]*y + a[13]*x OR a[14]*y - Z = *np.power(x,2) + *np.power(y,2) + if char[0] == "Z": + x = oldvariables[0] + y = oldvariables[1] + z = oldvariables[2] + aa = ( int(a[4]*x) & int(a[5]*y)) + if aa >= 1: + aa = 1 + if aa < 1: + aa = 0 + bb = ( int(a[6]*x) ^ int(a[7]*y)) + if bb >= 1: + bb = 1 + if bb < 1: + bb = 0 + cc = (int(a[11]*x) & int(a[12]*y)) + if cc >= 1: + cc = 1 + if cc < 1: + cc = 0 + dd = (int(a[13]*x) ^ int(a[14]*y)) + if dd >= 1: + dd = 1 + if dd < 1: + dd = 0 + + X = a[1] + a[2]*x + a[3]*y + (1-aa)*a[4]*x + aa*a[5]*y + (1-bb)*a[6]*x + bb*a[7]*y + Y = a[8] + a[9]*x + a[10]*y + (1-cc)*a[11]*x + cc*a[12]*y + (1-dd)*a[13]*x + dd*a[14]*y + Z = np.power(x,2) + np.power(y,2) + variables = (X,Y,Z) # [ - X = a[1] + a[2]*x + a[3]*y + a[4]|X|a[5] + a[6]|Y|a[7] - Y = a[8] + a[9]*x + a[10]*y + a[11]|X|a[12 ]+ a[13]|Y|a[14] - Z = *np.power(x,2) + *np.power(y,2) + if char[0] == "[": + x = oldvariables[0] + y = oldvariables[1] + z = oldvariables[2] + X = a[1] + a[2]*x + a[3]*y + a[4]*np.power(np.abs(x),a[5]) + a[6]*np.power(np.abs(y),a[7]) + Y = a[8] + a[9]*x + a[10]*y + a[11]*np.power(np.abs(x),a[12])+ a[13]*np.power(np.abs(y),a[14]) + Z = np.power(x,2) + np.power(y,2) + variables = (X,Y,Z) # \ - X = a[1] + a[2]*x + a[3]*y + a[4]sin(a[5]*x + a[6) + a[7]sin(a[8]*y + a[9]) - Y = a[10] + a[11]*x + a[12]*y + a[13]sin(a[14]*x + a[15) + a[16]sin(a[17]*y + a[18]) - Z = *np.power(x,2) + *np.power(y,2) + if char[0] == "\\": + x = oldvariables[0] + y = oldvariables[1] + z = oldvariables[2] + X = a[1] + a[2]*x + a[3]*y + a[4]*np.sin( a[5]*x + a[6]) + a[7]*np.sin( a[8]*y + a[9]) + Y = a[10] + a[11]*x + a[12]*y + a[13]*np.sin(a[14]*x + a[15]) + a[16]*np.sin(a[17]*y + a[18]) + Z = np.power(x,2) + np.power(y,2) + variables = (X,Y,Z) # ] - X = 10a[1] + [X + a[2sin(a[3]*y+a[4])]cos[2p/(13+10a[6])] + Y sin[2p/(13+10a[6])] - Y = 10a[5] - [X + a[2sin(a[3]*y + a[4])]sin[2p/(13+10a[6])] + Y cos[2p/(13+10a[6])] - Z = *np.power(x,2) + *np.power(y,2) + if char[0] == "]": + x = oldvariables[0] + y = oldvariables[1] + z = oldvariables[2] + X = 10*a[1] + (x + a[2]*np.sin(a[3]*y + a[4]))*np.cos(2*np.pi/(13+10*a[6])) + y*np.sin(2*np.pi/(13+10*a[6])) + Y = 10*a[5] - (x + a[2]*np.sin(a[3]*y + a[4]))*np.sin(2*np.pi/(13+10*a[6])) + y*np.cos(2*np.pi/(13+10*a[6])) + Z = np.power(x,2) + np.power(y,2) + variables = (X,Y,Z) # ^ - X = X + 0.1a[1]*y - Y = Y + 0.1(a[2]*x + a[3]*np.power(x,3) + a[4]*np.power(x,2)*y + a[5]*x*np.power(y,2) + a[6]*y + a[7]*np.power(y,3) + a[8]sin Z - Z = [Z + 0.1(a[9] + 1.3)] mod 2p - """ + if char[0] == "^": + x = oldvariables[0] + y = oldvariables[1] + z = oldvariables[2] + X = a[1]*y + Y = a[2]*x + a[3]*np.power(x,3) + a[4]*np.power(x,2)*y + a[5]*x*np.power(y,2) + a[6]*y + a[7]*np.power(y,3) + a[8]*np.sin(z) + Z = math.fmod(z + epsilon*(a[9] + 1.3), 2*np.pi) + X = x + epsilon * X + Y = y + epsilon * Y + Z = z + epsilon * Z + variables = (X,Y,Z) + return variables \ No newline at end of file