WOLFRAM NOTEBOOK

env=CreateCompilerEnvironment[];CompilerEnvironmentAppendTo[env,FunctionDeclaration[percolationSurvival,Function[{Typed[p,"Real32"],Typed[size,"MachineInteger"],Typed[cutoff,"MachineInteger"]},Block[{s=1,c=0,a=ConstantArray[0,size],b=ConstantArray[0,size],i},a[[Quotient[size+1,2]]]=1;While[s>0&&c<=cutoff,c++;s=0;If[Divisible[c,2],For[i=1,i<=size,i++,a[[i]]=If[(b[[Mod[i-2,size]+1]]==1||b[[i]]==1||b[[Mod[i,size]+1]]==1)&&RandomReal[]<p,s++;1,0]],For[i=1,i<=size,i++,b[[i]]=If[(a[[Mod[i-2,size]+1]]==1||a[[i]]==1||a[[Mod[i,size]+1]]==1)&&RandomReal[]<p,s++;1,0]]]];c]]]];
In[]:=
env
Out[]=
CompilerEnvironmentObject
SystemID:
MacOSX-x86-64
User Types:
0
User Functions:
0
PercolationSurvival=FunctionCompile[Function[{Typed[p,"Real32"],Typed[size,"MachineInteger"],Typed[cutoff,"MachineInteger"]},percolationSurvival[p,size,cutoff]],CompilerEnvironmentenv]
In[]:=
ParallelEvaluate[env=CreateCompilerEnvironment[];CompilerEnvironmentAppendTo[env,FunctionDeclaration[percolationSurvival,Function[{Typed[p,"Real32"],Typed[size,"MachineInteger"],Typed[cutoff,"MachineInteger"]},Block[{s=1,c=0,a=ConstantArray[0,size],b=ConstantArray[0,size],i},a[[Quotient[size+1,2]]]=1;While[s>0&&c<=cutoff,c++;s=0;If[Divisible[c,2],For[i=1,i<=size,i++,a[[i]]=If[(b[[Mod[i-2,size]+1]]==1||b[[i]]==1||b[[Mod[i,size]+1]]==1)&&RandomReal[]<p,s++;1,0]],For[i=1,i<=size,i++,b[[i]]=If[(a[[Mod[i-2,size]+1]]==1||a[[i]]==1||a[[Mod[i,size]+1]]==1)&&RandomReal[]<p,s++;1,0]]]];c]]]]]
In[]:=
ParallelEvaluate[PercolationSurvival=FunctionCompile[Function[{Typed[p,"Real32"],Typed[size,"MachineInteger"],Typed[cutoff,"MachineInteger"]},percolationSurvival[p,size,cutoff]],CompilerEnvironmentenv]]
CompiledCodeFunction
:CompiledCodeFunctionSignatureTypeSpecifier[{Real32,Integer64,Integer64}Integer64],InputCompile`Program[{},Function[{Typed[p,Real32],Typed[size,MachineInteger],Typed[cutoff,MachineInteger]},percolationSurvival[p,size,cutoff]]],ErrorFunctionAutomatic,InitializationNameInitialization_e4252a79_12c5_4c4a_9ac3_2ddfa3ae7131,ExpressionNameMain_ExprInvocation,CNameMain_CInvocation,FunctionNameMain,SystemIDMacOSX-ARM64,VersionData{14.,0,0},CompiledIRMacOSX-ARM64ByteArray
16.6 kB
,4,5177854352,5177854060,5177854144,5177851904,{"Real32", "Integer64", "Integer64"} -> "Integer64" is not recognised as a CompiledCodeFunction that was created by the Wolfram Compiler.
CompiledCodeFunction
:CompiledCodeFunctionSignatureTypeSpecifier[{Real32,Integer64,Integer64}Integer64],InputCompile`Program[{},Function[{Typed[p,Real32],Typed[size,MachineInteger],Typed[cutoff,MachineInteger]},percolationSurvival[p,size,cutoff]]],ErrorFunctionAutomatic,InitializationNameInitialization_2f60d537_1b6f_4487_81c4_f2c1a6ec0fdc,ExpressionNameMain_ExprInvocation,CNameMain_CInvocation,FunctionNameMain,SystemIDMacOSX-ARM64,VersionData{14.,0,0},CompiledIRMacOSX-ARM64ByteArray
16.6 kB
,4,4369828240,4369827948,4369828032,4369825792,{"Real32", "Integer64", "Integer64"} -> "Integer64" is not recognised as a CompiledCodeFunction that was created by the Wolfram Compiler.
CompiledCodeFunction
:CompiledCodeFunctionSignatureTypeSpecifier[{Real32,Integer64,Integer64}Integer64],InputCompile`Program[{},Function[{Typed[p,Real32],Typed[size,MachineInteger],Typed[cutoff,MachineInteger]},percolationSurvival[p,size,cutoff]]],ErrorFunctionAutomatic,InitializationNameInitialization_3a707729_aed5_4614_9ae6_3620a37407b4,ExpressionNameMain_ExprInvocation,CNameMain_CInvocation,FunctionNameMain,SystemIDMacOSX-ARM64,VersionData{14.,0,0},CompiledIRMacOSX-ARM64ByteArray
16.6 kB
,4,4331227536,4331227244,4331227328,4331225088,{"Real32", "Integer64", "Integer64"} -> "Integer64" is not recognised as a CompiledCodeFunction that was created by the Wolfram Compiler.
General
:Further output of CompiledCodeFunction::form will be suppressed during this calculation.
Out[]=
CompiledCodeFunction
Signature: {Real32,Integer64,Integer64}Integer64
,CompiledCodeFunction
Signature: {Real32,Integer64,Integer64}Integer64
,
161
,CompiledCodeFunctionSignatureTypeSpecifier[{Real32,Integer64,Integer64}Integer64],InputCompile`Program[{},Function[{Typed[p,Real32],Typed[size,MachineInteger],Typed[cutoff,MachineInteger]},percolationSurvival[p,size,cutoff]]],ErrorFunctionAutomatic,InitializationNameInitialization_a90b6ad7_b795_43e3_9d18_df50b1f342b2,ExpressionNameMain_ExprInvocation,CNameMain_CInvocation,FunctionNameMain,SystemIDLinux-x86-64,VersionData{14.,0,0},CompiledIRLinux-x86-64ByteArray
16.2 kB
,ExternalLibraryPaths{CompilerCoreRuntime},orcInstance66474240,orcModuleId66632368,targetMachineId65312944,140463831207632,140463831207424,140463831207536,140463831203840,{"Real32", "Integer64", "Integer64"} -> "Integer64"
Full expression not available
(
original memory size:
3.6 MB)
In[]:=
PercolationSurvival[.544,400,1000]
Out[]=
1001
In[]:=
ParallelTable[PercolationSurvival[.539,1000,10000],100]
Out[]=
{6,10001,125,10001,1,42,10001,985,1,121,3,15,10001,309,78,6,304,1068,115,10001,54,8,1,110,87,665,8,1605,57,10001,385,64,10001,6,2,10001,7,10001,62,6,423,10001,373,5,200,10001,10001,10001,221,1,1,4188,10001,3529,192,16,8,1858,3,12,10001,72,10001,1019,215,10001,4,457,35,13,6,10001,2,2,3,3,10001,2,10001,10001,14,6160,8182,1390,10001,10001,134,5,181,18,6,8315,10001,1,22,246,1,8,46,5}
In[]:=
pdata=ParallelTable[PercolationSurvival[.539,1000,40000],10000];
In[]:=
Histogram[pdata]
Out[]=
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.